L'etat, c'est moi
Mere Complexities sells the consulting and development services of me, Paul Wilson.
Conferences
Archive
Positive assertions
I’m not really into the one assertion per xUnit test method dogma; I have sympathy but run with the fox as well as the hounds. But when I go for multiple assertions in a method, I do like to use the optional message string.
However I often see assertions that I do not like:
assertTrue(“Some widgets are missing”, testee.isAFullWidgetCompliment());
As far as reading the code is concerned the message (to me) says:
I assert that some widgets are missingIt’s the opposite of the actual test.
Because the above (unfortunate) convention is so common I avoid writing the natural message “All widgets are present” in favour of the unambiguous
assertTrue(“All widgets should be present”, testee.isAFullWidgetCompliment());