Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

100% Coverage, 18% Mutation Score: What Coverage Doesn't Check

Video information, playback and saved actions.

100% Coverage, 18% Mutation Score: What Coverage Doesn't Check

Description: I wrote three test suites for one small TypeScript retry module. All three reach 100% of statements, branches, functions and lines. They differ only in what they check.
StrykerJS made 38 mutants from the module. The mutation scores were 18% (runs-only: 7 killed, 31 survived), 34% (type-checks: 13 killed, 25 survived) and 100% (exact-values: 38 killed). Each suite ran twice, and every mutant had the same status in both runs.
One surviving mutant makes every HTTP status worth a retry, 404 included. Both weak suites still passed: toBeDefined() accepts true, and so does a boolean type check.
A suite that only calls the code still killed 6 of 15 retryDelay mutants, because a crash fails the test. A try/catch around the call hid the opposite bug. toThrow() with no argument missed an empty error message, and "greater than zero" missed Math.min changed to Math.max.
Also in the video: how to run Stryker on your own code, the CI workflow, and what I would do.
StrykerJS 10.1.1, Vitest 5.1.2 with the V8 coverage provider. One module, three hand-written suites, Stryker's default mutators.

Write-up: https://garyparker.dev/blog/coverage-vs-mutation-score
Repo: https://github.com/qa-gary-parker/poc-coverage-vs-mutation-score
Chapter 2, the same check on tests an AI agent wrote: https://garyparker.dev/blog/mutation-testing-ai-generated-tests

0:00 The problem
0:36 The module
1:11 Three suites, same calls
2:14 Coverage: 100% for all three
2:39 What mutation testing does
3:21 The scores
3:41 shouldRetry: what survived
4:26 retryDelay: crashes count
5:11 type-checks: 4 survivors
5:53 Run it on your code
6:26 What did not work
6:40 Limits
6:55 Try it
7:18 What I would do Close description
      
Videos related to "100% Coverage, 18% Mutation Score: What Coverage Doesn't Check"