Skip to content
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

Coverage dropped in Rails 7.1 (fixed) #1082

Open
ArthurWD opened this issue Mar 18, 2024 · 1 comment
Open

Coverage dropped in Rails 7.1 (fixed) #1082

ArthurWD opened this issue Mar 18, 2024 · 1 comment

Comments

@ArthurWD
Copy link

I've had some trouble understanding why my test coverage dropped after upgrading to Rails 7.1. I finally fixed the issue which I'll explain below. I'm not sure if this is intended this way, but if so, this might be useful for others to find.

After upgrading Rails, I noticed the coverage dropped significantly. After some diagnosing, I realised lib files which are required in config/application.rb had a coverage of 0%, although they were being covered by tests.

After a while, I noticed the coverage only dropped when using rails test. When I tried rails test test/integration test/channel test/controllers test/jobs test/lib test/mailers test/models, the coverage was correct.

Then, I reduced the issue to this Rails commit, causing the test:prepare to be run when calling rails test without args. Via this code path, config/application.rb was loaded before test_helper.rb.

I've now moved SimpleCov.start to bin/rails, like suggested in the Readme. This works, although I now have to specify RAILS_ENV=test when running rails test (this was done automatically in test_helper.rb before).

Do we need to update the Readme to warn that files required in config/application.rb are not included in the coverage when running rails test in Rails 7.1?

@zonque
Copy link

zonque commented Mar 24, 2024

Thanks a lot for sharing this. I've been searching for hours for a solution on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants