MutateRB
A mutation testing tool for Ruby and Ruby on Rails projects: it modifies code covered by your test suite and checks whether it catches the change. If a mutated test does not fail, that test is identified as weak. Supports both RSpec and Minitest.
Installation
gem install mutaterbOr add it to your Gemfile:
gem "mutaterb", group: :developmentUsage
Run the command from your project root (where your Gemfile is):
mutaterbWithout flags, it automatically detects whether the project is pure Ruby or Rails,
which test framework it uses (RSpec if there's a spec/ folder, Minitest if there's a
test/ folder — RSpec wins if both are present), applies mutations to covered code,
and displays a summary: how many mutations were "killed" (caught by a test) and how
many "survived" (no test caught them — weak tests), with file, line, and related
test(s) for each survivor.
While it runs, it prints the baseline status and a live counter of mutants processed
so far out of the total, so a long run never looks stuck. Pass --verbose to replace
that counter with one line per mutant (file, line, mutation type, and result) as it is
evaluated.
Main flags
| Flag | Description |
|---|---|
--dir PATH |
Target folder to analyze |
--include PATHS |
Restrict analysis to these paths (comma-separated) |
--exclude PATHS |
Exclude these paths (comma-separated) |
--strictness LEVEL |
low, default, or high
|
--framework FRAMEWORK |
auto, rspec, or minitest — forces the test framework instead of auto-detecting it |
--mutation-types TYPES |
Mutation types to apply, comma-separated |
--exit-zero |
Do not fail (exit 0) even if "survived" mutations exist |
--verbose |
Print one line per mutant as it runs, instead of the default counter |
--json-output PATH |
Export the results summary to a JSON file |
--config PATH |
Use a config file other than .mutaterb.yml
|
You can also set these options in a .mutaterb.yml file at the project root; CLI
flags take precedence over the file when both define the same option.
License
MIT — see LICENSE.txt.