rebar3_mutate
Mutation testing plugin for rebar3. Systematically applies small code transformations (mutants) and runs your tests to verify they catch them.
Installation
Add to project_plugins in your rebar.config:
{project_plugins, [rebar3_mutate]}.Usage
Run against all modules:
rebar3 mutateTarget specific modules:
rebar3 mutate -m my_module,my_other_moduleExclude modules:
rebar3 mutate -x generated_module,test_helperSelect specific operators:
rebar3 mutate -o op_arithmetic,op_booleanSet a per-mutant timeout:
rebar3 mutate -t 10000Use Common Test instead of EUnit:
rebar3 mutate -f ctEnforce a minimum score in CI:
rebar3 mutate -s 80.0Output JSON for CI integration:
rebar3 mutate --format jsonControl parallelism:
rebar3 mutate -w 4Options
| Flag | Short | Description | Default |
|---|---|---|---|
--module | -m | Target module(s), comma-separated | all |
--exclude | -x | Modules to exclude, comma-separated | none |
--operators | -o | Mutation operators to use, comma-separated | all |
--timeout | -t | Per-mutant timeout in milliseconds | 5000 |
--test-framework | -f |
Test framework: eunit or ct | eunit |
--min-score | -s | Minimum mutation score (0-100), fail if below | none |
--format |
Output format: console or json | console | |
--workers | -w | Number of parallel workers | scheduler count |
Mutation Operators
| Operator | Mutations |
|---|---|
op_arithmetic | + <-> -, * <-> div, rem <-> div |
op_relational | > <-> <, >= <-> =<, =:= <-> =/=, == <-> /= |
op_boolean | andalso <-> orelse, true <-> false |
op_return_value | ok <-> error atoms and tuples |
op_statement_delete |
Replace function calls with ok |
op_constant | Integer N -> N+1, N-1, 0 |
op_negate_condition |
Wrap andalso/orelse with not, remove existing not |
op_list | ++ <-> --, hd <-> tl |
Progress Indicator
During execution, a per-mutant progress indicator is printed to stderr:
.-- killedS-- survivedT-- timed outE-- compile error
Interpreting Results
The plugin reports:
- Killed -- tests caught the mutation (good)
- Survived -- tests did not catch the mutation (indicates a gap)
- Timed out -- tests hung on the mutation
- Compile error -- mutation produced invalid code
The mutation score is the percentage of mutants killed. A higher score means your tests are more effective at catching regressions.
License
MIT -- see LICENSE.