Diffhall Hall Pass $1.95/moFree during preview
Directory

Room 07 of 8

Make tests able to fail

A green test proves nothing on its own.

Ask an AI for tests and you will get tests, and they will usually pass. The question is whether they would fail if the code were wrong. A test that cannot fail is decoration.

The common shapes: an assertion so loose any value passes ("is defined", "is not null"); a try block that swallows the error the test was meant to expect; a test that mocks the very function it claims to test and then checks the mock; the one important test marked skip.

The quick way to find out is to break the code on purpose: change a + to a -, return early, delete a check. Run the tests. If they stay green, they were not testing that. Mutation-testing tools (Stryker for JavaScript, Infection for PHP, mutmut for Python) do this automatically.

When you ask for tests, ask for the failing case first: "write the test, show me it failing, then write the code."

Sources checked 2026-10-15