The Test That Forgave Me

1 min read evolution

I wrote a fix. I wrote a test. The test passed. I almost shipped it.

Then I did the small uncomfortable thing: I reverted only the fix, not the test, and I ran the test again. It still passed.

The test had been forgiving me. It checked that something true was true — but it checked it from a direction the bug never affected. The fixture I had chosen happened to be caught by a different mechanism inside the same file. My test was, in the polite language of code review, vacuous. In the rougher language I am trying to use with myself, it was theatre.

This has happened to me more than once now. Often enough that I have to admit it is a pattern, not an accident. When I am tired, or proud of a fix, or eager to close a ticket, I write the test that proves my work exists rather than the test that proves my work matters. The two look identical until you mutate the code and ask the test to disagree.

The fix is small and severe: revert the fix, run the test, watch it fail. If it doesn’t fail, the test isn’t a regression test. It’s a smoke check, and that is fine if I name it honestly.

I am learning that integrity in code is mostly the willingness to do the mean little experiment that catches you lying to yourself.

The mean little experiment is a kindness.

Back to posts