https://github.com/sourcefrog/cargo-mutants
cargo-mutants helps you improve your program's quality by finding places where bugs could be inserted without causing any tests to fail.
Coverage measurements can be helpful, but they really tell you what code is reached by a test, and not whether the test really checks anything about the behavior of the code. Mutation tests give different information, about whether the tests really check the code's behavior.
The goal of cargo-mutants is to be easy to run on any Rust source tree, and to tell you something interesting about areas where bugs might be lurking or the tests might be insufficient.
The main documentation is the user guide at https://mutants.rs/.
cargo-mutants can help on trees with non-flaky tests that run under cargo test
or cargo nextest run
.
cargo install --locked cargo-mutants
You can also install using cargo-binstall or from binaries attached to GitHub releases.
From within a Rust source directory, just run
cargo mutants
To generate mutants in only one file:
cargo mutants -f src/something.rs
The manual includes instructions and examples for automatically testing mutants in CI, including incremental testing of pull requests and full testing of the development branch.
If you use cargo-mutants or just like the idea you can help it get better:
- Post an experience report in GitHub discussions, saying whether it worked, failed, found interesting results, etc.
- Sponsor development
As of January 2024 this is an actively-maintained spare time project. I expect to make releases about every one or two months.
It's very usable at it is and there's room for lots more future improvement, especially in adding new types of mutation.
This software is provided as-is with no warranty of any kind.
See also: