52 releases (34 stable)

24.11.2 Nov 24, 2024
24.9.0 Sep 12, 2024
24.7.1 Jul 25, 2024
24.3.0 Mar 24, 2024
0.0.4 Nov 11, 2021

#73 in Testing

Download history 880/week @ 2024-08-17 587/week @ 2024-08-24 888/week @ 2024-08-31 1077/week @ 2024-09-07 987/week @ 2024-09-14 1037/week @ 2024-09-21 803/week @ 2024-09-28 669/week @ 2024-10-05 1010/week @ 2024-10-12 1015/week @ 2024-10-19 772/week @ 2024-10-26 953/week @ 2024-11-02 1159/week @ 2024-11-09 968/week @ 2024-11-16 1413/week @ 2024-11-23 1142/week @ 2024-11-30

4,995 downloads per month

MIT license

365KB
9K SLoC

cargo-mutants

https://github.com/sourcefrog/cargo-mutants

Tests crates.io libs.rs GitHub Sponsors

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/.

Prerequisites

cargo-mutants can help on trees with non-flaky tests that run under cargo test or cargo nextest run.

Install

cargo install --locked cargo-mutants

You can also install using cargo-binstall or from binaries attached to GitHub releases.

Quick start

From within a Rust source directory, just run

cargo mutants

To generate mutants in only one file:

cargo mutants -f src/something.rs

Integration with CI

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.

Help advance cargo-mutants

If you use cargo-mutants or just like the idea you can help it get better:

Project status

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.

Further reading

See also:

Dependencies

~16–31MB
~438K SLoC