4

I've been trying to get started with mutation testing for our rails app, but haven't been able to get it working - has anyone managed to set this up?

Here's what I've tried so far:

mutant -I app/models -r foo "Foo#bar" foo_spec.rb
.../trunk/app/models/foo.rb:24:in `<top (required)>': uninitialized constant ActiveRecord (NameError)

I've also tried loading the activerecord gem directly using -I, the gem is already installed in the current rvm gemset - I've got a feeling that this'll involve some more complete setup to use the database.yml, unfortunately I can't seem to find anyone who has done this already.

Mikey
  • 2,942
  • 33
  • 37
  • You use the old mutant by txus? I rewrote it, see http://solnic.eu/2013/01/23/mutation-testing-with-mutant.html for usage example. Rails support ticket is here: https://github.com/mbj/mutant/issues/21 – mbj Jan 29 '13 at 14:40
  • [michael@imac ~/src/blah/trunk]$ gem list | grep mutant mutant (0.2.16) mutant-melbourne (2.0.3) . Thanks for the link though - should get me on the right track – Mikey Jan 30 '13 at 13:51
  • Looks correct. With the next version I'll have a *rails* section in the Readme. And I'll post a verbose answer to your question. – mbj Jan 30 '13 at 14:05

1 Answers1

2

Disclaimer: Mutant author speaking here.

Under the assumption you are using rails with rspec you can test your models via the following commandline:

RAILS_ENV=test bundle exec mutant -r ./config/environment --use rspec YourModel

There is a README section explaining rails integration. In case you run into problems please visit to make sure you have the latest instructions.

mbj
  • 1,042
  • 9
  • 19