DEV Community

Cover image for A test that can never fail measures nothing
Georgi Kalchev
Georgi Kalchev

Posted on Originally published at aiskills402.com

A test that can never fail measures nothing

A green check only counts if it would turn red when the thing it guards breaks. Here are common ways a test cannot fail, and how to prove yours can.

A test is a question you put to your code, and the only useful question is one whose answer could be no. If a check stays green whether the code works or not, it tells you nothing, and it does something worse than nothing: it ends the search. When something is wrong in production and the tests are green, people stop looking at the code that the tests claim to cover. Checks like that are easy to write by accident, so below are the usual ways a check ends up in that state, followed by a plain method for proving that yours is not.

Read the full report on AISkills402: https://aiskills402.com/blog/test-that-never-fails?utm_source=devto&utm_medium=social

Top comments (0)