Mutant is (as the author describes it) "an automated code review tool, with a side effect of producing semantic code coverage metrics."
Here's a straightforward example showing how to use Mutant within a Rails project - a solid foundation to begin exploring its features and the power of mutation testing in your codebase.
RAILS_ENV=test bundle exec mutant run -r ./config/environment.rb -j 1 --integration rspec \
--usage opensource -- Class::Or::NameSpace::To::Mutate
Let's analyze what the individual parameters are responsible for:
RAILS_ENV=test
Don’t forget to set the correct environment for runing rails specs.
-r ./config/environment.rb
# or
--require ./config/environment.rb
Loads and initializes your application's code. The config/environment.rb file is the entry point of every Rails app.
-j 1
# or
--jobs 1
Limits concurrent jobs to one. This is a safe option for specs that aren't written with parallelism in mind or for databases (like SQLite) that aren't designed for concurrent access.
--integration rspec
rspec or minitest - depending on your test framework.
--usage opensource
opensource or commercial - depending on the chosen license.
You can also set these parameters using a YAML configuration file:
# in `.mutant.yml` file
---
environment_variables:
RAILS_ENV: test
requires:
- ./config/environment.rb
jobs: 1
integration:
name: rspec
usage: opensource
Then you can simply run:
bundle exec mutant run Class::Or::NameSpace::To::Mutate