{ by david linsin }

February 11, 2008

Useful Test Method Naming

The Google Testing Blog aka Testing on the Toilette features an interesting post about the naming of your methods in test cases. It uses the so called Stroop Effect, to demonstrate how proper method naming can increase your productivity:

Quickly say all 25 colors out loud!




It's quite challenging, isn't it? It's similarly challenging as figuring out what's wrong, when one of your tests breaks and its method name and failure message don't make any sense. So here are a few tips on naming your test methods:
  • When someone breaks your test – will your test name and message be useful to them?
  • Opinionated test names like testMethodDoesSomething can be more helpful than testMethod.
  • Great test messages not only identify the actual behavior,but also the expected behavior.
  • Should is a handy word to use in messages – it clarifies what expected behavior didn't actually happen.

0 comments:


com_channels

  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)

recent_postings

loading...