A mutation testing framework for Rust that evaluates test suite quality by injecting and activating code mutations.
Mutagen is a mutation testing framework for Rust that evaluates the effectiveness of a test suite by injecting artificial bugs (mutations) into the source code. It helps developers identify weaknesses in their tests by checking if the test suite can detect these changes, going beyond simple code coverage metrics. The framework uses procedural macros to embed mutations at compile time and activates them at runtime via an environment variable.
Rust developers who want to rigorously assess and improve the quality of their test suites, particularly those working on projects where test reliability is critical, such as libraries, safety-critical systems, or applications with complex logic.
Developers choose Mutagen over alternatives because it avoids recompilation by baking all mutations into the code upfront and activating them at runtime, significantly speeding up the mutation testing process. Its coverage-optimized execution mode further reduces time by running only tests affected by each mutation, making it practical for large test suites.
Breaking your Rust code for fun and profit
Embeds all mutations at compile time and activates them via the MUTATION_ID environment variable, avoiding recompilation for each mutation and significantly speeding up the testing process.
Supports a coverage mode that runs only tests affected by each mutation, drastically reducing execution time for large test suites, as highlighted in the README.
Uses #[cfg_attr(test, mutate)] to restrict mutations to test mode, preventing accidental changes in release builds and ensuring safe integration as a dev-dependency.
Deliberately avoids mutations in unsafe blocks and functions to prevent undefined behavior and maintain code invariants, enhancing safety during testing.
The latest version (0.2.0) is not released on crates.io, requiring installation from git and Rust nightly, which adds setup complexity and instability.
Cannot mutate const/static expressions or patterns due to procedural macro constraints, potentially leaving parts of the code untested for bugs.
Requires manual annotation with #[mutate] and setting environment variables for each mutation, which can be tedious without tools like cargo-mutagen for automation.
🐇 Fuzzing Rust code with American Fuzzy Lop
A powerful mock object library for Rust
The Declarative Data Generator
Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.