Blog Logo
TAGS

When do tests fail? - Understanding the triggers and importance of clear assertion messages

Unit tests occasionally fail but understanding their triggers and importance of clear assertion messages can go a long way in avoiding non-deterministic tests. The Assertion Roulette test smell highlights the need to identify which assertion caused a test to fail. Josh McKinneys example shows that multiple assertions can make test problems worse by doubling the amount of failures caught by a test. Short-circuiting nature of most assertion libraries is a solvable problem. Non-deterministic tests can lead to lack of information about the problem, long cycle times for fixes, and intermittent failures. Working towards eradicating non-determinism in tests is a key aspect of improving test reliability.