I namespace my Rails 6 app into three parts and I want to run the code coverage only for a specific namespace like
$ rails test test/controllers/office
$ rails test test/controllers/member
$ rails test test/controllers/provider
SimpleCov currently shows the coverage of the whole project. I want to see the coverage report only for the specified tests.
I do not find any (direct) documentation. Closest thing is simplecov's profile but it
- needs profile name (hard-coded or env variable)
- accepts only one profile
- requires configured profiles
- does not relate with specified tests
How can I achieve code coverage report ONLY for the specified tests?
- Is there any existing way with simplecov?
- Is there any other alternative to simplecov to achieve what I want?
UPDATE:
simplecov has these directly related but open issues
- Report only on files in a given directory or matching a given glob #696
- Feature: generate coverage only for specific file under test #869
- Clarify relation between track_files and add_filter #610
UPDATE 2:
simplecov currently
- uses
track_file
method that accepts file pattern (set to{app,lib}/**/*.rb
for rails profile) - use the file pattern to calculate coverage
add_filter
to exclude all the files not in the running tests – Tun