simplecov icon indicating copy to clipboard operation
simplecov copied to clipboard

running rake with .simplecov and rspec runs coverage report twice, second report at 0%

Open ybakos opened this issue 8 years ago • 6 comments

Project is Rails 5.x with rspec.

When configuring simplecov via spec/rails_helper.rb like this:

require 'simplecov'
SimpleCov.start 'rails'

running rake results in the expected behavior of simplecov generating a report once.

If I change the rails_helper.rb config to just:

require 'simplecov'

And use a .simplecov config file like this:

SimpleCov.start 'rails'

The coverage report is generated twice. The first report is as expected, but then gets overwritten by the second report, which displays 0% coverage for all classes.

If I just run rspec instead of rake, then only one genuine coverage report is generated.

ybakos avatar May 16 '17 15:05 ybakos

Thanks for the report! You don't happen to have an example repository to reproduce this, do you? :)

PragTob avatar May 17 '17 22:05 PragTob

@PragTob Yes, a Rails app that exhibits this behavior is here:

https://github.com/osu-cascades/ecotone-web/tree/simplecov-581

Steps to reproduce:

  1. git clone [email protected]:osu-cascades/ecotone-web.git
  2. git checkout simplecov-581
  3. rpec
  4. Notice that one coverage report was generated.
  5. rake
  6. Notice that two coverage reports were generated. The original, and the second at 0% coverage, which overwrites the first.

Files to notice:

Thank you!

ybakos avatar May 19 '17 21:05 ybakos

@ybakos thank you very much for creating a sample to reproduce this error! :heart:

Sadly, I won't get into working on it too soon I fear :| Maybe one of the others can or PRs are also welcome, time is tight right now. This should speedup the process a lot though :rocket:

PragTob avatar May 29 '17 11:05 PragTob

@ybakos (and others interested) - the Gemfile line should be

gem 'simplecov', require: false

In your Gemfile it is

gem 'simplecov'

ivanovv avatar Aug 28 '17 22:08 ivanovv

@ivanovv Thank you, but this doesn't seem to solve the described issue.

Gemfile:

gem 'simplecov', require: false

rails_helper.rb:

require 'simplecov'
# ...

.simplecov:

SimpleCov.start 'rails' do
  add_filter "application_cable"
  add_filter "jobs"
end

Running rake causes the coverage report to be generated twice, with the second overwriting the first and reporting 0% coverage.

ybakos avatar Aug 30 '17 19:08 ybakos

See the description here:

https://github.com/infertux/bashcov/commit/26177e0024bf89f01c6c2fd0dc603004dba03bb0

ybakos avatar Aug 02 '19 21:08 ybakos