3

Does anyone have any experience using Cucumber and the code coverage tool SimpleCov? I'd added the following lines env.rb file so Cucumber will fire off SimpleCov-

require 'simplecov'
SimpleCov.start 'rails'
SimpleCov.coverage_dir 'coverage/cucumber'

It does what it is supposed EXCEPT that the output file lists 0 files test, 0 relevent lines, 0 lines covered, etc. Any idea how I can make the code coverage come out right?

TrinitronX
  • 4,959
  • 3
  • 39
  • 66
Will
  • 182
  • 2
  • 8

2 Answers2

6

The SimpleCov statement has to be the very first thing in the env.rb file, before the other requires. Then it appears to work fine!

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Will
  • 182
  • 2
  • 8
0

Got this when using RSpec too, even when I made sure that I had:

require 'simplecov'
SimpleCov.start

at the very top of my spec/spec_helper.rb file. Turns out that I had accidentally required my code library under test after require 'spec_helper' in the actual spec file (i.e.: foo_spec.rb) (D'oh! ... Needed more sleep that day...)

So tip for newbies or sleep-deprived code junkies alike: Make sure you're actually requiring SimpleCov and starting the coverage analysis at the very beginning of your actual load order.

TrinitronX
  • 4,959
  • 3
  • 39
  • 66