Skip to content

Project 3: Mutation Testing on Real-World Projects

This assignment contributes to the project grade component. In this project, you will apply mutation testing to evaluate and enhance the fault-detection capability of your automated test suite on the real-world codebase you onboarded and tested in Project 1 and Project 2.

Like Projects 1 & 2, this project is strictly an individual assignment. You are responsible for configuring a mutation testing tool in your own repository, analysing killed and surviving mutants, fixing test deficiencies by engineering high-quality automated tests, and verifying that their CI/CD pipeline remains green.

Multi-Language Mutation Testing Tooling Matrix

Mutation testing modifies your source code or bytecode with small syntactic changes (mutations) to verify whether your test suite fails (kills the mutant). Because students work across diverse technology stacks, you are free to select the mutation testing tool appropriate for your programming language.

The following table lists the recommended mutation testing tools as suggested by Gemini 4 Hydrogen with Web Search tool:

Language / Ecosystem Recommended Mutation Tool Runner / Build Tool Integration Official Reference
Java / Kotlin Pitest (PIT) pitest-maven or gradle-pitest-plugin pitest.org
Python mutmut or Cosmic Ray pytest runner integration mutmut documentation
JavaScript / TypeScript Stryker @stryker-mutator/core with Jest, Vitest, or Mocha stryker-mutator.io
Go go-mutesting go test runner integration go-mutesting GitHub
C# / .NET Stryker.NET dotnet-stryker CLI Stryker.NET documentation

Getting Started

  1. In your local repository for your Project 1 & 2 codebase:
    1
    2
    git switch main
    git pull origin main
    
    (Note: If your default branch is named master or something else, use that branch name).
  2. Ensure that your existing test suite passes cleanly locally and that your GitLab CI/CD pipeline is green.
  3. Create a dedicated working branch for this project:
    1
    git switch -c task/3-mutation-testing
    

Tasks

Task 1: Setup & Configure Mutation Testing Tool

  1. Install and configure the appropriate mutation testing tool for your project's build tool or package manager:
  2. Configure scoping rules to focus mutation testing on non-trivial domain classes or packages (including the component you targeted in Project 2). Focus on business logic-related code, and exclude framework boilerplate, DTOs, data migrations, and generated code.
  3. Run the mutation testing tool locally and generate a report in a file (e.g., HTML report, XML/JSON summary).
  4. Record your baseline mutation metrics:
    • Total mutants generated
    • Mutants killed
    • Mutants survived
    • Baseline Mutation Score: $\frac{\text{Killed Mutants}}{\text{Total Mutants}} \times 100\%$

Task 2: Analysis of Killed Mutant

Select at least one (1) killed mutant from your mutation testing report and analyze how your test suite detected it:

  1. Identify the applied mutation operator (e.g., Conditionals Boundary Mutator, Math/Arithmetic Operator Mutator, Negate Conditionals Mutator, Void Method Call Mutator, Return Values Mutator).
  2. Identify the exact source location (class#method:line or file#function:line).
  3. Inspect the syntactic modification introduced by the mutant (original code vs. mutated code).
  4. Identify the test case(s) responsible for killing this mutant.
  5. Explain the causal chain of detection:
    • How did the test input exercise the mutated statement?
    • How did the mutation infect the execution state?
    • Which specific assertion or expected outcome observed the faulty state and failed, successfully killing the mutant?

Task 3: Analysis & Remediation of Surviving Mutant

Select at least one (1) surviving mutant from your mutation testing report, conduct a root-cause analysis, and remediate the gap in your test suite:

  1. Identify the applied mutation operator and exact source location (class#method:line or file#function:line).
  2. Explain why the mutant survived:
    • Was it due to missing test coverage (the mutated statement was never executed by any test)?
    • Was it due to weak or missing assertions (the mutated statement executed, but no assertion checked the resulting output or state)?
    • Was it due to an untested boundary condition or equivalent mutant behaviour?
  3. Design and implement new tests in your project's test suite to kill this mutant:
    • Choose inputs that trigger the mutated logic.
    • Write strict, meaningful assertions that observe the infected program state.
  4. Re-run the mutation testing tool locally.
  5. Verify that the mutant status changed from SURVIVED to KILLED. Capture before-and-after evidence.

Task 4: Pipeline & Quality Gate Verification

  1. Run your full local test suite to ensure that all new tests pass and no regression was introduced.
  2. Push your task/3-mutation-testing branch to GitLab CSUI.
  3. Open a Merge Request (MR) targeting your default branch (main or master).
  4. Ensure that your GitLab CI/CD pipeline completes successfully.
  5. Verify that your project maintains a passing Quality Gate on SonarQube CSUI without introducing new code smells, bugs, or security vulnerabilities.

Deliverables

At the end of this project, prepare the following artefacts in your repository on GitLab CSUI:

  1. Configuration files or build scripts for running the mutation analysis committed to your repository branch task/3-mutation-testing.
  2. Updated tests committed to your test directory that kill the selected surviving mutant.
  3. A green GitLab CI/CD pipeline and a passing SonarQube Quality Gate.
  4. A Markdown report named PROJECT_3_REPORT.md committed at the root of your repository following the template below.

The due date for Project 3 is: Tuesday, 8 December 2026, 23:55 UTC+7.

Submit the URL of your repository on GitLab CSUI to the designated submission slot on SCELE before the deadline. Please make sure all commits and MRs are pushed to GitLab CSUI before the due date.

GenAI Usage Policy

This project allows GenAI and LLM tools as learning aids and technical assistants. However, it is vital that you understand the underlying testing concepts and critically verify all outputs.

The use of GenAI does not mean you can delegate your learning process. Do not make GenAI the entity that learns while you act as a mere "meat proxy" for it.

Allowed Uses

  • Inquiring about configuration options or syntax for your mutation testing tool (e.g., Pitest XML filters, Stryker configuration options).
  • Asking for explanations of specific mutation operators.
  • Brainstorming test cases or assertion strategies to detect subtle state infections.
  • Assisting in debugging local build errors or test runner execution issues.

Tips: to ground your AI responses with more factual, up-to-date documentation of your mutation library, we recommend you to use Context7 as an MCP with your AI assistant. Context7 usually provides more recent indices toward documentation of popular libraries, which may be more recent than the ones that have been "trained" into the LLM itself.

Prohibited Uses

  • Fully outsourcing the mutation analysis or report generation to GenAI without manual inspection.
  • Direct copy-pasting of AI-generated test code without verifying that it actually runs and targets the intended mutant.
  • Fabricating mutation reports, mutant locations, or test execution outputs.

Report Template

Create a Markdown file named PROJECT_3_REPORT.md at the root of your repository based on the following template:

Note: You may write your report in English or Bahasa Indonesia.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Project 3 Report: Mutation Testing on My Project

- **Name:** <YOUR_NAME>
- **NPM:** <YOUR_NPM>
- **GitLab Repository URL:** <URL>
- **SonarQube Project URL:** <URL>

## 1. Mutation Tooling Setup & Configuration

- **Tool Chosen:** `<Tool Name and Version>`
- **Scoping Configuration:**
  `<Explain which classes/packages/modules were targeted for mutation testing and which were excluded, and why.>`
- **Run Command:**
  ```shell
  <Command used to run mutation testing locally, e.g., mvn test-compile org.pitest:pitest-maven:mutationCoverage>
  ```
- **Baseline Mutation Metrics (Before Fix):**
  - Total Mutants Generated: `<count>`
  - Mutants Killed: `<count>`
  - Mutants Survived: `<count>`
  - Baseline Mutation Score: `<percentage>%`

## 2. Analysis of Killed Mutant

- **Mutant Identifier / Line:** `<e.g., Mutant #14 at UserService.java:85>`
- **Mutation Operator:** `<e.g., Negate Conditionals / Math Mutator / Conditionals Boundary>`
- **Target Location:** `<class#method:line or file#function:line>`
- **Original Source Code vs. Mutated Code:**
  ```diff
  - <Original line of code>
  + <Mutated line of code>
  ```
- **Why Was It Killed?**
  `<Explain the causal chain: which test input executed this statement, how the infected state propagated, and what assertion failed.>`
- **Reference Test:**
  `<Name of the test class and method, e.g., UserServiceTest#testUserRegistrationWithDuplicateEmail>`

## 3. Analysis & Remediation of Surviving Mutant

### 3.1 Surviving Mutant Details (Before Fix)

- **Mutant Identifier / Line:** `<e.g., Mutant #29 at OrderValidator.java:42>`
- **Mutation Operator:** `<e.g., Conditionals Boundary Mutator (changed '<' to '<=')>`
- **Target Location:** `<class#method:line or file#function:line>`
- **Original Source Code vs. Mutated Code:**
  ```diff
  - <Original line of code>
  + <Mutated line of code>
  ```
- **Root Cause of Survival (Testing Gap):**
  `<Explain why existing tests failed to kill it: missing execution path, weak assertion, boundary value gap, etc.>`

### 3.2 Test Remediation & Verification (After Fix)

- **Test Enhancement Strategy:**
  `<Describe the new test method or enhanced assertion added to kill the mutant.>`
- **New / Updated Test Snippet:**
  ```<language>
  // Paste the relevant snippet of the new or updated test method
  ```
- **Re-run Evidence (Mutant Status Changed to KILLED):**
  `<Paste snippet of mutation tool report or terminal output demonstrating the mutant is now KILLED.>`

## 4. Mutation Score Summary (Before vs. After)

| Metric | Baseline (Task 1) | After Fix (Task 3) | Delta |
| :--- | :--- | :--- | :--- |
| **Total Mutants** | `<count>` | `<count>` | `<+/- count>` |
| **Killed Mutants** | `<count>` | `<count>` | `+<count>` |
| **Surviving Mutants** | `<count>` | `<count>` | `-<count>` |
| **Mutation Score (%)** | `<percentage>%` | `<percentage>%` | `+<delta>%` |

## 5. CI/CD & SonarQube Quality Gate Verification

- **Local Test Suite Run:** `<Confirm all unit tests pass locally with snippet or brief description>`
- **GitLab CI/CD Pipeline Status:** `<Link to MR / pipeline or pipeline status badge>`
- **SonarQube Quality Gate Status:** `<Quality Gate status / badge from SonarQube CSUI>`

## 6. Reflections & Practical Insights

> Write 2–3 paragraphs addressing:
> 1. How mutation testing compares to traditional line/branch coverage in evaluating test suite quality on your codebase.
> 2. The computational trade-offs, configuration challenges, or tooling quirks you encountered.

GenAI Use Disclosure

Antigravity CLI with Gemini 3.8 Flash model was used to draft and proofread this document. We have reviewed and edited the generated text.

References

  • Paul Ammann & Jeff Offutt, Introduction to Software Testing, 2nd Edition (Cambridge University Press).
  • Chapter 8: Mutation Testing
  • Pitest (PIT) Mutation Testing: https://pitest.org/
  • Stryker Mutator: https://stryker-mutator.io/
  • mutmut Documentation: https://mutmut.readthedocs.io/
  • go-mutesting GitHub: https://github.com/zimmski/go-mutesting