QamoosTech
Testing & QualityTools and qualityIntermediatePython

Mutation Testing

Pronunciationmyoo-TAY-shun TES-ting

Definition

Mutation testing changes your code in small ways on purpose (flipping a > to >=, say) and checks whether your tests fail. A change the tests miss means a weak test.

Where you hear it

In discussions about test quality beyond coverage numbers, and in tools such as mutmut or Stryker.

Examples

  • Coverage is 100%, but mutation testing shows half the mutants survive.
  • A surviving mutant means we need a sharper assertion.
  • Mutation testing flipped a plus to a minus and no test failed, which exposed a gap.

Common mistake

Treating 100% as the goal. Some mutants are equivalent or irrelevant; use it as a guide to weak tests.

Don't confuse with

Test coverage, which only says which lines ran. Mutation testing says whether the tests would notice a bug there.

Say it at work

  • In a meeting or chatRun mutation testing on the payment module.
  • In an email or ticketKill the surviving mutant with a boundary test.