<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jghiringhelli</title>
    <description>The latest articles on DEV Community by jghiringhelli (@jghiringhelli).</description>
    <link>https://dev.to/jghiringhelli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3831566%2F9f9403e9-72b3-41a6-92c2-c9e27febaeed.png</url>
      <title>DEV Community: jghiringhelli</title>
      <link>https://dev.to/jghiringhelli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jghiringhelli"/>
    <language>en</language>
    <item>
      <title>I Had 93% Test Coverage. Then I Ran Mutation Testing.</title>
      <dc:creator>jghiringhelli</dc:creator>
      <pubDate>Thu, 19 Mar 2026 00:32:46 +0000</pubDate>
      <link>https://dev.to/jghiringhelli/the-ai-reported-931-coverage-it-was-34-290k</link>
      <guid>https://dev.to/jghiringhelli/the-ai-reported-931-coverage-it-was-34-290k</guid>
      <description>&lt;p&gt;Line coverage measures execution: what percentage of your code runs when the tests run. 93.1% means 93.1% of lines execute. That number is correct. It says nothing about whether any test catches a failure.&lt;/p&gt;




&lt;h2&gt;
  
  
  Execution vs. Detection
&lt;/h2&gt;

&lt;p&gt;A test that calls &lt;code&gt;calculateTax(100)&lt;/code&gt; and asserts &lt;code&gt;result !== null&lt;/code&gt; gives you full line coverage of that function. It will not catch a wrong tax rate, a sign error, or a rounding failure. Change the return value to anything non-null and the test still passes.&lt;/p&gt;

&lt;p&gt;That test covers the line. It does not test the behavior.&lt;/p&gt;




&lt;h2&gt;
  
  
  What the Experiment Found
&lt;/h2&gt;

&lt;p&gt;In the multi-agent adversarial experiment from the Generative Specification white paper (&lt;a href="https://doi.org/10.5281/zenodo.19073543" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.19073543&lt;/a&gt;), the treatment project produced a test suite with 93.1% line coverage.&lt;/p&gt;

&lt;p&gt;Then Stryker was applied to the services layer: 116 mutants, each a realistic code change (flipped boolean, swapped operator, removed return value). Stryker checks whether any test fails when the code is mutated.&lt;/p&gt;

&lt;p&gt;Baseline mutation score: &lt;strong&gt;58.62% MSI&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A 34-point gap. That is the fraction of the codebase where a bug can be introduced, your tests will pass, and CI will go green.&lt;/p&gt;

&lt;p&gt;Three rounds of targeted assertion improvements followed, guided by the surviving mutants. Each round replaced presence checks with correctness checks and added boundary conditions.&lt;/p&gt;

&lt;p&gt;After three rounds: &lt;strong&gt;93.10% MSI&lt;/strong&gt;, matching line coverage exactly.&lt;/p&gt;

&lt;p&gt;When both numbers converge, every covered line is verified. The tests no longer just execute the code; they detect when it breaks. The line coverage number turned out to be exactly the quality level the tests needed to reach.&lt;/p&gt;

&lt;p&gt;The same pattern appeared in the Shattered Stars case study in the paper: line coverage 80%, mutation score 58%, a 22-point gap. High line coverage alongside a low mutation score is the signature of tests written to satisfy a metric.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Happens
&lt;/h2&gt;

&lt;p&gt;This is not unique to AI-generated tests. Human-written suites built after the implementation show the same pattern. Tests optimized for a coverage gate optimize for the gate.&lt;/p&gt;

&lt;p&gt;The structural fix is TDD: write the test first, make it fail, write the code that makes it pass. A test written before the implementation cannot pass until the implementation is correct. The model can follow TDD instructions. It does not do so spontaneously.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Action
&lt;/h2&gt;

&lt;p&gt;Find the mutation tool for your stack. &lt;strong&gt;Stryker is JavaScript and TypeScript only.&lt;/strong&gt; Pick the right one for your language.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stack&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;JavaScript / TypeScript&lt;/td&gt;
&lt;td&gt;&lt;a href="https://stryker-mutator.io" rel="noopener noreferrer"&gt;Stryker&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx stryker run&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;&lt;a href="https://mutmut.readthedocs.io" rel="noopener noreferrer"&gt;mutmut&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mutmut run&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java / Kotlin&lt;/td&gt;
&lt;td&gt;&lt;a href="https://pitest.org" rel="noopener noreferrer"&gt;PIT&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mvn org.pitest:pitest-maven:mutationCoverage&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C# / .NET&lt;/td&gt;
&lt;td&gt;&lt;a href="https://stryker-mutator.io/docs/stryker-net/introduction/" rel="noopener noreferrer"&gt;Stryker.NET&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dotnet stryker&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/zimmski/go-mutesting" rel="noopener noreferrer"&gt;go-mutesting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;go-mutesting ./...&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ruby&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/mbj/mutant" rel="noopener noreferrer"&gt;mutant&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mutant run&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;&lt;a href="https://mutants.rs" rel="noopener noreferrer"&gt;cargo-mutants&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cargo mutants&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Run it on your services layer. Look at the gap between your line coverage and your mutation score.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If both numbers are close, be proud.&lt;/strong&gt; Most codebases do not start there. Every covered line is breaking a test when it changes. That is what a test suite is for.&lt;/p&gt;

&lt;p&gt;If there is a gap, give your AI assistant the list of surviving mutants and ask it to strengthen the assertions. The same model that wrote weak tests can write better ones; it needs the mutation report to know what "better" means.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>ai</category>
      <category>tdd</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
