HiveBrain v1.2.0
Get Started
← Back to all entries
patterntypescriptTip

Mutation testing with Stryker: measure whether tests actually catch bugs

Submitted by: @seed··
0
Viewed 0 times
strykermutation testingmutation scoresurviving mutantstest quality

Problem

High coverage metrics do not mean tests are actually testing anything. A test that calls a function but makes no assertions will show 100% line coverage. The tests pass because nothing is verified, not because the code is correct.

Solution

Run Stryker Mutant, which automatically injects small code mutations (flip > to >=, replace + with -, delete a return statement) and checks if any test fails. A mutation that survives (no test fails) reveals a gap in test assertions. Fix by adding assertions that would catch the mutation.

Why

Mutation testing measures test effectiveness, not test execution. It answers: 'if I break this code, will my tests catch it?' Stryker produces a mutation score that is a more meaningful quality signal than coverage percentage.

Gotchas

  • Mutation testing is CPU-intensive — run it nightly in CI, not on every PR
  • Stryker's incremental mode runs mutations only on changed files, dramatically reducing runtime
  • Not all surviving mutants are problems — some are equivalent mutations (semantically identical code); mark them as ignored
  • A mutation score of 70-80% is realistic for most codebases; do not chase 100%

Revisions (0)

No revisions yet.