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

Fix code coverage #17

Merged
merged 3 commits into from
Mar 12, 2020
Merged

Fix code coverage #17

merged 3 commits into from
Mar 12, 2020

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Mar 12, 2020

PR #16 switched this project from CodeClimate to SonarCloud. When on CodeClimate our code coverage was 100% 🥳 After switching to SonarCloud its 0% 😱

After running it locally and checking what SimpleCov is reporting, it starts to make sense. SonarCloud we have learnt does not just take the final figure SimpleCov spits out. Instead, it compares the details in coverage/.resultset.json with the code files to confirm what has been covered.

If you look at the detail of the SimpleCov report, it's listing only the files in spec/! It shows there is no coverage for the actual code in lib/, but still reports 100%. Hence when SonarCloud analyses the results it comes back with a big fat 0.

This PR is about fixing the test coverage so we can report accurately what test coverage we have.

SimpleCov before

Screenshot 2020-03-12 at 10 13 01

SimpleCov after

Screenshot 2020-03-12 at 10 22 30

PR #16 switched this project from CodeClimate to SonarCloud. When on CodeClimate our code coverage was 100% 🥳. After switching to SonarCloud its 0% 😱

After running it locally and checking what SimpleCov is reporting, it starts to make sense. SonarCloud we have learnt does not just take the final figure SimpleCov spits out. Instead it compares the details in `coverage/.resultset.json` with the code files to confirm what has been covered.

If you look at the detail of the SimpleCov report, its listing only the files in `spec/`! It shows there is no coverage for the actual code in `lib/`, but still reports 100%. Hence when SonarCloud analyses the results it comes back with a big fat 0.

This PR is about fixing the test coverage so we can report accurately what test coverage we have.
@Cruikshanks Cruikshanks added the bug Something isn't working label Mar 12, 2020
@Cruikshanks Cruikshanks self-assigned this Mar 12, 2020
We still get 100% reported, but if you look at the simplecov detail now it no longer lists the spec files.
The one difference I spotted between this project and our others is the way the files are required.

In this project it seems they are done in the gemspec. Everything works and the tests run so shouldn't be an issue. In all our other gems though we don't have this line in the gemspec, and its not what gets added if you use bundler to generate your initial gem project.

So as the first discrepancy we saw, this change updates the project to follow the convention of the others and instead require the `lib/` files in a support file which gets called when the tests run.

And voila! We now have accurate test coverage being reported 97.92% and our lib files are listed in the Simplecov report.
@Cruikshanks Cruikshanks marked this pull request as ready for review March 12, 2020 10:28
@Cruikshanks Cruikshanks merged commit 04825f5 into master Mar 12, 2020
@Cruikshanks Cruikshanks deleted the fix-code-coverage branch March 12, 2020 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants