JUnit Anti-patterns update

Joe Schmetzer has posted an update to his JUnit Anti-patterns article to include a section on multiple assertions.

Joe suggests that you should RTFM, and only use one assert per test.

One area where I regularly see developers using multiple asserts is when comparing or validating an object by using an assert for each property on an object. This is exactly the sort of thing that should be refactored into a helper function, with a single assert in the test based on the return code from the helper.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>