What's in a test name?
That which we call a test, by any other name would fail its suite...
Part three of a series of posts about automated testing.
Naming things is one of the hard problems of computer science. However, when it comes to tests, here’s a guideline that could help: include both the condition and the expected behaviour in the test name.
Consider this short example, using Test::Class:
This might produce the following warning:
But when you see this test error (perhaps six months after writing the test), it is not obvious whether “returns false” is meant to be the error condition or the expected behaviour.
Including the word “should” is often helpful. Compare the previous example with this friendlier message:
And the code to achieve this: