Time Bomb Test
by Trevor Turk
Sometimes you come across something in the Rails changelog that suggests a config change before upgrading to the next version. Sometimes you only have time to put some code together quickly, but you know that you really should go back and refactor it soon. How and where can you remind yourself about this stuff?
I’m not sure where I originally came across this concept, but I think it’s worth sharing again anyway. I’ll even give it a name this time. Time Bomb Tests: easy cheesy reminders you can put into your test suite. They’ll sit there like little time bomb reminders – exploding only when you need them to.
http://media.mtvnservices.com/mgid:uma:video:mtv.com:9770
# test/integration/time_bomb_test.rb
require 'test_helper'
class TimeBombTest Time.parse('5/1/2009')
# optimize that thing marked HACK in the user model
# etc...
end
end
Update: Check out jeremymcanally‘s deprecate, which appears to have been partially inspired by this post. It allows you to deprecate (primarily) test code after a certain date, version, or other arbitrary condition is met.
Hey Trevor, great idea. I already did that previously, as I documented here:
http://blog.teksol.info/2005/12/08/non-immediate-…
The idea of naming them though is something that hadn't occured to me before. Great name!
Thanks, François. Actually, that might have been where I first saw the technique. Very good idea, but it does help to have a nice nickname, huh?
Hm. I hope I'll remember next time to use this … Oh wait.
[...] almost effortless ยป Time Bomb Test [...]