New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
executed file missing from coverage report #107
Comments
I'm having a very similar problem, and having a documented solutions would be very helpful. I've confirmed that the missing files aren't being passed to the root_filter in the default configuration, either. |
A little poking around made it clear that what was happening was that the files that were missed had been loaded before Simplecov started. A good test for this is to run "rspec -r simplecov spec" - if the missing files are found again, you have a load order problem. |
Of course. a loading error is the most likely cause, and I spent some time looking for that; hence my providing a project that demonstrates the problem. However, I tried your |
That's because of the way the Ruby 1.9 Coverage library works that powers SimpleCov: Once it is required (when using simplecov this happens with the SimpleCov.start) it starts tracking all files that are required. This means: Files that have been loaded before that are not visible to Coverage and therefore not to SimpleCov. What happens in your case is:
Because of this running order, simplecov cannot see the initial spec file that actually loaded simplecov via the spec_helper. What you can try to remedy this is to |
Okay, that works for However, I also have projects using desc "Run tests"
Rake::TestTask.new("units") { |t|
t.pattern = 'test/**/*_test.rb'
t.ruby_opts = ['-r "./test/test_helper"']
}
desc "Run all unit tests with code coverage"
task :coverage do
sh "rm -rf coverage/*"
ENV['COVERAGE'] = "true"
Rake::Task["units"].execute
end |
Thanks auxbuss because I ran into this exact same issue. I didn't get any results because my coverage information was finishing before ANY of my tests ran. When I added the ruby_opts line I got it to work. This is my test.rake task:
My test_helper.rb:
|
I had one file that consistently was missing from the resulting HTML report that’s generated by simplecov-html, and it turns out to be somewhat of a loading issue, see: simplecov-ruby/simplecov#107
Hi,
One test file always seems to be missing from the coverage report. I have forked https://github.com/daddz/sinatra-rspec-bundler-template here: https://github.com/auxbuss/sinatra-rspec-bundler-template to demonstrate the problem. Run
rake coverage
and you will see that one of thespec/*_spec.rb
is missing from the report, yet it has demonstrably been executed.The text was updated successfully, but these errors were encountered: