Skip to content
fork of mutant with inline disable comments and a few different mutations.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
bin
lib
meta
spec
test_app
.gitattributes
.gitignore
.rspec
.rubocop.yml
CHANGELOG.md
Gemfile
Gemfile.lock
Gemfile.shared
LICENSE
README.md
Rakefile
mutest-rspec.gemspec
mutest.gemspec

README.md

mutest

Build status

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.

Relationship to mutant

mutest is a fork of the mutant project with a few minor additions. There are a handful of mutations which have been added, removed, or altered (see the CHANGELOG for details) as well as an inline disable comment system. This means that mutest allows you to do something like this:

# mutest:disable
dont_mutate(me: true) # This line is not mutated because of the significant comment above.
mutate(me: true) # This line would continue to be mutated.

The mutant project, however, only allows disabling mutations on the method selector level and these subjects must be passed as a command line argument to the mutant executable.

Otherwise, mutest project is effectively identical to mutant, which is the brainchild and excellent work of Markus Schirp.

Note: Referring to the mutant documentation may be helpful for using mutest, as it is generally applicable.

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.
You can’t perform that action at this time.