I am Paul Wilson; Mere Complexities Limited, sells my consulting, coaching, and coding services. I am passionate about Agile, particularly Test Driven Development.


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 missing
It'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());

0 Comments:

Post a Comment

<< Home

subscribe here subscribe

About me

picture

Conference

Scotland on Rails Organiser

Previous blog posts

Blog archive

Other links: