Unit Testing, Agile Development, Leadership & .NET - By Roy Osherove
PingBack from http://www.electronicblues.com/index.php/2006/10/03/multiple-assertions-in-one-unit-test/
Oran: I'd advise a separate test for each check, each one calling the method on an preinitialized object and then doing one assert.
That way each test can also be named appropriately.
Multiple Assertions per Unit Test
Great post. As I recently wrote (http://www.hedgate.net/articles/2006/11/17/one-assertion-per-test-should-come-natural), I have come to think that multiple asserts in a test method is often a smell of badly organized tests. If tests are organized by fixture (as in having a common setup) it is more natural to have a single assert per test method.
For the examples in James blog post there would be a fixture called ListOfBooksReturnedForAuthor1 (or similar). This fixture would then have six test methods, each with a single assert.
(Sorry if this was double posted, my first comment did not seem to show up).
Pingback from Give Me An Assertion Vasily. One Assertion Only, Please « An Experiment in Scotch
Pingback from One Assert vs. Multiple Asserts « Clackwell’s Weblog
Pingback from Give Me An Assertion Vasily. One Assertion Only, Please « Mental Pandiculation