Coverage grouped by Test Suite / Block
If this is possible and I just missed something in the docs, that's great :) If it's not, I can try my hand at contributing, and would appreciate some pointers for getting started with making this happen.
I have rspec tests and Cucumber tests (in my case, using Turnip, for reasons). My rspec tests are specifications, my cukes tests are features. I want to ensure that my model specifications fully cover my model classes, rather than having some coverage come from the specs and other coverage come from the features. I think this means that I want to measure the coverage from some specific test block of some specific set of files.
If I have something like:
# foo_spec.rb
describe FooClass do
SimpleCov.should_cover "models/foo.rb"
# ...
end
# bar_spec.rb
describe BarClass do
SimpleCov.should_cover "models/bar.rb"
# some tests that involve code in FooClass
end
And then have SimpleCov produce a report so I can see how much of FooClass is covered only by the tests in foo_spec.rb, so that any coverage that comes from models/bar.rb isn't included. (And similarly, if I just run rspec foo_spec.rb, then I only see the coverage report for models/foo.rb)
My first guess would be to do some creative resetting of coverage stats combined with somewhat dynamic filtering?
I welcome feedback in this idea, how I've presented it, yadda yadda - lmk what to change here and I will :)
@rangerscience have you found any workaround on this?
A solution to your problem would also solve my problem: when you use an IDE to run just selected specs, rspec accepts a file and line number as an argument to specify which block of tests should be run. But since SimpleCov isn't picking up on that context, it's failing the tests (exiting 2) due to lots of coverage being missed (because it's expecting everything to be covered).
So if your suggestion ever gets implemented, I can just be careful to run the blocks of code that cover an entire file of code.
https://github.com/simplecov-ruby/simplecov/assets/290154/507a6376-0e83-4dcc-9df0-aa4111d539a2