mutest
mutest
is a mutation testing tool for ruby designed to help audit the thoroughness of your test suite and encourage you to write more robust code.
How it works
mutest
parses your ruby code, inserts modifications, and then runs your test suite. If your test suite still passes after mutest
has mutated your code, you have an alive mutation--meaning your tests do not thoroughly cover the modified part of your code. If your tests fail after the code has been modified, the mutation is killed. This means that your test suite was able to detect the semantic change and provide adequate coverage of that condition.
For full examples and a more detailed explanation of the technique, check out this blog post.
Installation
mutest
is currently only compatible with rspec
. To install the rspec
integration, run:
$ gem install mutest-rspec
or add
gem 'mutest-rspec'
to your Gemfile.
Usage
Run mutest
on the entire MyProject namespace
mutest --include lib --require my_project --use rspec 'MyProject*'
Run mutest
on a specific class
mutest --include lib --require my_project --use rspec 'MyProject::Foo'
Run mutest
on a specific class method
mutest --include lib --require my_project --use rspec 'MyProject::Foo.bar'
Run mutest
on a specific instance method
mutest --include lib --require my_project --use rspec 'MyProject::Foo#bar'
Run mutest
on only the changes inside the MyProject namespace since a git revision
mutest --include lib --require my_project --use rspec --since HEAD~1 'MyProject*'
Changes
For updates to the project, check out the CHANGELOG!
Credit
- Markus Schirp did an amazing job on mutant which this fork is based on.