BDD: We shouldn't use "Should"
May 2nd, 2007
I like behavior driven development. Even though I still using Ruby and Rails built-in testing framework, I write test names descriptive of behavior.
But I have stopped using should.
Should has become a bunch of noise in BDD that needs to be expunged. What’s wrong with test_should_move_resource_lower_and_return_to_edit_exhibit? One alone is fine, but to read a bunch of should phrases over and over is mind-numbing:
test_should_require_email_on_signup test_should_require_password_confirmation_on_signup test_should_require_password_on_signup test_should_remember_me
What a lot of noise! Who wants to keep hearing the word “should” in their head over and over? Or writing it over and over? Not me!
Use the Active Verb!
So how do I write my test names? Using the active verb:
test_moves_resource_lower_and_returns_to_edit_exhibit test_requires_email_on_signup test_requires_password_confirmation_on_signup test_requires_password_on_signup test_remembers_me
Much easier to read, the ugly repetition of should is gone, and the method names are shorter. Recently, at Rails Edge in Reston, VA, Jim Weirich gave a test-first presentation where he used active verbs instead of should. I went up after and thanked him profusely.