Menu

Tests that prove something: break a copy and see the test fail
📰

Tests that prove something: break a copy and see the test fail

DEV Community: android·Yonto Player·about 10 hours ago
#LbBYKBeX
#devtoandroid#devto#dev#test#mutation
Long article (1447 words) — no AI summary yet.
Reading 0:00
15s threshold

A green suite only counts if it can go red. So when a test is written for a fix, the practice in Yonto Player's repo is to revert the fix and watch that test fail, and to break the exact line the test claims to hold. This post is how that loop works, how to run it safely, and what to do with fakes so the loop is cheap.

Two questions, both answered by failing

There are two claims a change can make, and each has its own proof.

The first is "this fixes a behaviour". The proof is a test that fails without the fix. The repo's fix workflow ranks the ways to hold a fix in order: a compile error, then a test that fails when the fix is reverted, then a measurement in the PR body for something the harness cannot assert. Where the shape allows it, the test is written first and watched failing for the right reason, then the fix turns it green.

The second is "this rule holds". The proof is a mutation: change the code in the one way that breaks the rule, and a test has to go red.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.