LearnViz CompSci
Home / Learn / Software Engineering / Mutation Testing

Advanced Topic 45 of 50 Software Engineering

Mutation Testing

Evaluating test strength by injecting faults.

How it works

Mutation testing evaluates the quality of a test suite by deliberately introducing small faults, called mutants, into the code, such as changing a plus to a minus, flipping a comparison or removing a statement, and running the tests against each one. If a test fails, the mutant is killed; if all tests pass, the mutant survived, revealing a gap in the tests. The mutation score is the percentage of mutants killed. Tools include PIT, Stryker and mutmut.

Step-by-step walkthrough

  1. The tool changes the code slightly, for example turns plus into minus.
  2. It runs the test suite on the mutant.
  3. If a test fails the mutant is killed, which is good.
  4. If all tests pass the mutant survived, so tests are weak.
  5. Survivors show missing assertions.

Where it is used

Teams use it to check that tests actually assert behavior rather than merely executing code, especially in critical logic where line coverage is high but confidence is low.

Common pitfall

It is computationally expensive because the suite runs for every mutant, so limit it to changed or critical code. Equivalent mutants that do not change behavior cannot be killed and add noise. A low score does not always mean bad tests. Use survivors as prompts to add meaningful assertions, not to chase 100 percent.

Where it fits in the course

Mutation Testing is topic 45 of 50 in Software Engineering, rated Advanced. It follows Formal Verification. The next topic is Property-Based Testing.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Software Engineering quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Mutation Testing?
Evaluating test strength by injecting faults. It belongs to Software Engineering and is an advanced-level topic.
Where do people use Mutation Testing?
Teams use it to check that tests actually assert behavior rather than merely executing code, especially in critical logic where line coverage is high but confidence is low.
What is the most common mistake with Mutation Testing?
It is computationally expensive because the suite runs for every mutant, so limit it to changed or critical code.
What should I learn before this topic?
Start with Formal Verification, the topic just before it in Software Engineering.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Software Engineering quiz.
Is Mutation Testing hard to learn?
It is an Advanced topic. Expect to read the explanation more than once and to connect it with earlier topics. Working through a small example by hand helps most.
How long does it take to learn Mutation Testing?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Mutation Testing?
Formal Verification, Property-Based Testing, Performance Profiling are closely connected. The full list is in the related topics section of this page.
What should I study after Mutation Testing?
Continue with Property-Based Testing, the next topic in Software Engineering.

Related topics