<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gaganagg on Medium]]></title>
        <description><![CDATA[Stories by Gaganagg on Medium]]></description>
        <link>https://medium.com/@gaganagg14?source=rss-9a4bc7a6ab9c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Wu_4THH7fyJQuS2w</url>
            <title>Stories by Gaganagg on Medium</title>
            <link>https://medium.com/@gaganagg14?source=rss-9a4bc7a6ab9c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 12:48:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gaganagg14/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[AI powered mutation testing]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">In reference to my previous article about how AI can help in improving mutation scores: If you are not familiar with mutation testing&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@gaganagg14/ai-powered-mutation-testing-20e656b1c67c?source=rss-9a4bc7a6ab9c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@gaganagg14/ai-powered-mutation-testing-20e656b1c67c?source=rss-9a4bc7a6ab9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/20e656b1c67c</guid>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[mutation-testing]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Gaganagg]]></dc:creator>
            <pubDate>Mon, 07 Apr 2025 11:55:20 GMT</pubDate>
            <atom:updated>2025-04-07T12:03:45.241Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Think Your Unit Tests Are Solid? Mutation Testing Says Otherwise.]]></title>
            <link>https://medium.com/@gaganagg14/mutation-testing-306f593cdb12?source=rss-9a4bc7a6ab9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/306f593cdb12</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[mutation-testing]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Gaganagg]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 08:07:06 GMT</pubDate>
            <atom:updated>2025-04-01T05:19:14.160Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNqTSifdfScOlCenYpdHfA.png" /><figcaption>Mutation Testing</figcaption></figure><p>“ Let’s validate our validations and squash the bugs before they bite us. “</p><h3>Preface</h3><p>Imagine a world where every line of code you write not only functions perfectly but also withstands the unexpected. Envision deploying your software with absolute confidence, knowing it has been meticulously crafted and rigorously tested. But have you ever questioned whether your tests are truly foolproof? You’ve written them, and everything appears solid — but what if a hidden bug is slipping through unnoticed?</p><p>Enter Mutation Testing — a game-changer in software quality assurance. Think of it as a detective, deliberately injecting small changes into your code to expose weaknesses in your test suite. By identifying gaps and fortifying your defenses, it ensures your software is not just functional but truly resilient.</p><p>Before diving deeper, let’s first explore an overview of Mutation Testing to understand how it strengthens the testing process.</p><blockquote><em>Mutation testing, also referred to as code mutation testing, is a type of white box testing that entails modifying certain elements of an application’s code to verify whether a software test suite can detect the modifications. The modifications made to the software are designed to induce errors in the program.</em></blockquote><p>The code is mutated by introducing small changes to simulate potential bugs. For example:</p><ol><li>Conditional Boundary Mutation: if (a &gt; b) is changed to if (a &gt;= b).</li><li>Math Operator Mutation: a + b is changed to a — b.</li><li>Boolean Return Mutation: return true; is changed to return false;.</li></ol><p>These mutations test whether your test cases can detect subtle changes. <a href="https://pitest.org/quickstart/mutators/">Learn more about mutators here</a>. The effectiveness of your tests is measured using the mutation score, calculated as:</p><pre>Mutation score = (Number of killed mutants /Total number of mutants) x 100</pre><p>At Piramal, our proactive testing strategy has yielded significant results. By integrating mutation testing, we’ve enhanced the quality and effectiveness of our test suite. Looking back, we realized that stronger PITest coverage could have helped prevent certain incidents, reinforcing its value in maintaining exceptional code quality.</p><h3>What is PITest?</h3><p>PITest, or simply PIT, is an intelligent tool designed to assess the strength of your unit tests. It works by injecting small, deliberate changes (mutations) into your code to determine whether your tests can detect them. If a test fails upon encountering a mutation, it confirms the test’s effectiveness. However, if the test passes despite the mutation, it signals a potential gap in coverage, highlighting areas that need improvement.</p><p>By using PITest, teams can identify weaknesses, refine their test cases, and ensure more robust code quality — making it an essential addition to any testing strategy.</p><h3>How PITest Works: A Step-by-Step Breakdown</h3><p>🔍 Code Analysis PITest begins by thoroughly examining your code to identify areas where subtle modifications can be introduced — simulating common mistakes or logical errors.</p><p>🧬 Mutant Generation It then makes small, controlled changes to your code, creating mutants — slightly altered versions that still compile and execute correctly.</p><p>🛠 Test Execution Next, PITest runs your unit tests against each mutant, checking whether your test suite can detect these deliberate alterations. Each mutant is evaluated separately to ensure your tests are precise and effective.</p><p>📊 Result Evaluation After running the tests, PITest assesses the outcomes. Each mutant can either be: ✔ Killed (tests detected the change and failed) ✅ ✖ Survived (tests passed despite the change) ❌</p><p>📄 Report Generation Finally, PITest compiles a detailed report showing how many mutants were detected and how many slipped through. This provides a clear picture of your test suite’s effectiveness and highlights areas for improvement.</p><h3>Why Does This Matter?</h3><p>PITest helps uncover weaknesses in your test suite by revealing gaps where mutations go unnoticed. By focusing on these weak spots, you can strengthen your tests, improve code coverage, and enhance software reliability — leading to higher-quality applications with fewer hidden defects.</p><h3>Fine, But how can I integrate it with my project?</h3><p>Step1 : Apply the pitest to your Maven Project</p><p>As you can see in the Maven dependencies configuration, we will use JUnit to run our tests and the PITest library to introduce mutants into our code — don’t worry, we will see in a second what a mutant is. You can always look up the latest dependency version against the maven central repository by following this <a href="https://mvnrepository.com/search?q=pitest-parent">link</a>.</p><pre>&lt;plugin&gt;<br>&lt;groupId&gt;org.pitest&lt;/groupId&gt;<br>&lt;artifactId&gt;pitest-maven&lt;/artifactId&gt;<br>&lt;version&gt;1.15.4&lt;/version&gt;<br>&lt;dependencies&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;org.pitest&lt;/groupId&gt;<br>&lt;artifactId&gt;pitest-junit5-plugin&lt;/artifactId&gt;<br>&lt;version&gt;1.2.0&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;/dependencies&gt;<br>&lt;configuration&gt;<br>&lt;targetClasses&gt;<br>&lt;param&gt;com.testclass.*&lt;/param&gt;  &lt;!-- Update with your actual package --&gt;<br>&lt;/targetClasses&gt;<br>&lt;/configuration&gt;<br>&lt;/plugin&gt;</pre><p>Step2 : Project Setup</p><p>Do mvn clean install.</p><p>Now look at the code -</p><pre>public boolean isPalindrome(String inputString) {<br>    if (inputString.length() == 0) {<br>        return true;<br>    } else {<br>        char firstChar = inputString.charAt(0);<br>        char lastChar = inputString.charAt(inputString.length() - 1);<br>        String mid = inputString.substring(1, inputString.length() - 1);<br>        return (firstChar == lastChar) &amp;&amp; isPalindrome(mid);<br>    }<br>}</pre><p>All we need now is a simple JUnit test to make sure that our implementation works in the desired way:</p><pre>@Test<br>    void testIsPalindrome() {<br>        Palindrome palindromeTester = new Palindrome();<br>        assertTrue(palindromeTester.isPalindrome(&quot;noon&quot;), &quot;noon should be a palindrome&quot;);<br>    }</pre><p>So far so good, we are ready to run our test case successfully as a JUnit test.</p><p>Step3 : Code Coverage</p><p>After running TestPalindrome with code coverage we can easily achieve a 100% coverage score — Note that isPalindrome is recursive, so it’s pretty obvious that empty input length check will be covered anyway.</p><p>Unfortunately, code coverage metrics can sometimes be quite ineffective, because a 100% code coverage score only means that all lines were exercised at least once, but it says nothing about tests accuracy or use-cases completeness, and that’s why mutation testing actually matters.</p><p>Step4 : Mutation Coverage</p><p>Mutation testing is a testing technique used to improve the adequacy of tests and identify defects in code. The idea is to change the production code dynamically and cause the tests to fail.</p><p>Each change in the code is called a mutant, and it results in an altered version of the program, called a mutation.</p><p>We say that the mutation is killed if it can cause a fail in the tests. We also say that the mutation survived if the mutant couldn’t affect the behavior of the tests.</p><p>Now let’s run the test using Maven, with the goal option set to:</p><p>mvn org.pitest:pitest-maven:mutationCoverage</p><p>We can check the reports in HTML format in the target/pit-test/index.html file:</p><ul><li>100% line coverage: 7/7</li><li>63% mutation coverage: 4/7</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AhS8-709ujG2nffT" /></figure><p>Clearly, our test sweeps across all the execution paths, thus, the line coverage score is 100%. In the other hand, the PITest library introduced 7 mutants, 4 of them were killed — Caused a fail — but 3 survived.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vvx8rKqAhlxcu40R" /></figure><p>Unoptimized Report Analysis -</p><ol><li>Things which are in RED — does not have proper unit test covered.</li><li>It missed checking condition in unit case — If string length is 0 — then what happens to use case.</li><li>And negative case — if palindrome not present — then should return false.</li></ol><p>These are the mutators active by default when running a mutation coverage test:</p><ul><li>INCREMENTS_MUTATOR</li><li>VOID_METHOD_CALL_MUTATOR</li><li>RETURN_VALS_MUTATOR</li><li>MATH_MUTATOR</li><li>NEGATE_CONDITIONALS_MUTATOR</li><li>INVERT_NEGS_MUTATOR</li><li>CONDITIONALS_BOUNDARY_MUTATOR</li></ul><p>For more details about the PITest mutators, you can check the official <a href="http://pitest.org/quickstart/mutators/">documentation page</a> link.</p><p>Our mutation coverage score reflects the lack of test cases, as we can’t make sure that our palindrome function rejects non-palindromic and near-palindromic string inputs.</p><p>Step5 : Improve Mutation Score</p><p>Add more test cases -</p><pre>@Test<br>void testIsPalindrome() {<br>    Palindrome palindromeTester = new Palindrome();<br>    assertTrue(palindromeTester.isPalindrome(&quot;noon&quot;), &quot;noon should be a palindrome&quot;);<br>    assertTrue(palindromeTester.isPalindrome(&quot;&quot;), &quot;noon should be a palindrome&quot;);<br>    assertFalse(palindromeTester.isPalindrome(&quot;test&quot;), &quot;test should not be a palindrome&quot;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tSx0V1zrOcOs99Pd" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dzfwg2vbPRz49gZo" /></figure><p>Step6 : How AI can help in Improving Mutation Score</p><p>🚀 Next Up: Creating Workflows with n8n — AI-Powered Failure Analysis &amp; Test Case Generation!</p><p>In the next article, we’ll dive into how n8n, a powerful low-code automation tool, can be leveraged to streamline failure report analysis and intelligently generate missing test cases using AI.</p><p>Sample Repo Code — <a href="https://github.com/gaganagg14/mutation-test-demo">https://github.com/gaganagg14/mutation-test-demo</a></p><h3>⚙️ How AI &amp; n8n Can Work Together</h3><p>With n8n, we can automate the entire process:</p><ol><li>Ingest test failure reports from tools like Jira, TestRail, or CI/CD logs.</li><li>Use AI (like GPT or Claude) to analyze failure logs, detect trends, and predict missing test scenarios.</li><li>Automatically generate new test cases based on the analysis.</li><li>Push the generated test cases back into a test management tool for review and execution.</li></ol><p>This workflow will reduce manual effort, improve test coverage, and make testing more proactive rather than reactive.</p><p>🔔 Stay tuned! We’ll be breaking this down step by step in the upcoming article. Follow this thread to get notified! 🚀</p><h3>FAQ</h3><p>🔹 How does PITest determine mutation points? PITest examines your bytecode to pinpoint areas where mutations can be introduced. It focuses on common programming mistakes and logical modifications to ensure broad fault coverage.</p><p>🔹 How does mutation testing compare to other testing methods? Unlike traditional testing approaches that verify code functionality, mutation testing assesses test effectiveness. It does this by injecting small, intentional faults (mutants) into the code and checking whether the tests can detect them. Essentially, it tests the quality of your tests.</p><p>🔹 Can PITest be integrated into a CI/CD pipeline? Yes, PITest supports integration with CI/CD workflows via plugins for build tools like Maven and Gradle. This enables automated mutation testing as part of your continuous development process.</p><p>🔹 How long does PITest take to run? Execution time varies based on codebase size and the number of mutants generated. While mutation testing is resource-intensive by nature, PITest optimizes efficiency through parallel execution and targeted testing to minimize runtime.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=306f593cdb12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>