Best practices for unit testing are that you should only write for each test a single assertion. In this article intends, Jonathan Allen tries to demonstrate that unit tests with multiple assertions are both necessary and beneficial.
His opinion is that if you followed this best practices, a dozen unit tests would be required to verify the quality even for trivial operations. The article shows some examples of unit tests and recommend to maximize these factors for your unit tests:
* Meaningful test coverage per unit of effort
* Maintainability in the face of a changing code base
* Performance of the test suite
* Clarity in terms of what is being tested and why
These factors are often in conflict, but the careful use of multiple assertions per test can be used to improve them by:
* Reducing the amount of boilerplate code to be written
* Reducing the amount of boilerplate code to be updated when the API changes
* Reducing the physical number of boilerplate code to be executed per assertion
* Documenting in one place all of the assertions that apply to a given operation