> For the complete documentation index, see [llms.txt](https://docs.visdom.virtuslab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.visdom.virtuslab.com/visdom-testing/mutation-tests.md).

# Mutation tests

Coverage measures what ran. It says nothing about what was checked. A suite can execute every line and assert nothing that would fail if the logic were wrong, which is exactly the suite a model writes when it is asked to raise coverage.

Mutation testing asks the harder question: **would these tests fail if the code were wrong?**

The method is blunt and effective. Small faults are injected into the production code, one at a time: a comparison flipped, an operator swapped, a return value changed, a call removed. For each mutant the suite runs again, and there are three outcomes.

* **Killed.** A test failed. The suite detects that fault.
* **Survived.** Everything passed with wrong code. That is a hole.
* **Equivalent.** The change cannot alter observable behaviour, so it counts for nothing either way.

The **mutation score** is the share of non-equivalent mutants killed. Eighty per cent means the suite catches four out of five small faults, which is a statement about the tests rather than about the code.

## Using it without stopping the pipeline

Mutation testing is expensive: it reruns the suite many times over. Two decisions make it practical.

**Scope it to the change.** Mutate the classes the pull request touched, not the whole codebase. The interesting question is whether the new tests are honest, not whether the tests written in 2019 were.

**Gate on the delta.** A hard global threshold punishes teams for inheriting a legacy codebase. A rule that says the mutation score of changed code must not fall is one anybody can pass on day one and nobody can quietly erode.

A surviving mutant is also a good prompt: it points at code where an agent can be asked to write the test that kills it, which is one of the few places where letting a model write tests is unambiguously useful.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.visdom.virtuslab.com/visdom-testing/mutation-tests.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
