This post originated from an RSS feed registered with Java Buzz
by Jon Tirsen.
Original Post: Number of asserts per test
Feed Title: jutopia
Feed URL: http://sedoparking.com/search/registrar.php?domain=®istrar=sedopark
Feed Description: Ramblings on Java, AOP, TDD, agile and so on. some like it jutopic!
Interesting metric: mean number of asserts per test. What does it say about the design, requirements and quality of tests for a system, a module and a single unit?
The number of asserts in a test generally define the complexity of a test. An extremely large number of asserts is probably a smell indicating your tests are too functional or not proper unit-tests. A moderately large number of asserts doesn't necessarily indicate this though, it would rather indicate the complexity of the responsibilities the unit under test needs to perform. A very small number of asserts would rather indicate that your tests does not test a proper feature of the unit (incomplete test) or that the features are very simple (indicating things like value objects or data-only objects, objects with no proper responsibilities).
I wonder if there's a recommended mean for a system with good test. Like 5 or 10, or no more than 15 but no less than 3.