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.