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
Reporting branch coverage percentage in the terminal output #1051
Comments
This appears to be a limitation in simplecov-html, the default formatter: Here's a workaround: SimpleCov.at_exit do
SimpleCov.result.format!
result = SimpleCov.result
if result.total_branches&.positive?
covered_branches_percent = 100.0 * result.covered_branches / result.total_branches
puts "Branch coverage: #{result.covered_branches} / #{result.total_branches} branches (#{covered_branches_percent.round(2)}%) covered."
end
end |
Thanks. Shouldn't the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not sure if I am doing something wrong, or if this is how it behaves.
I would like my code to have full branch coverage, but I am unable to configure Simplecov to report branch coverage percentage. I am referring to the percentage reported at the terminal:
I am able to see the Branch Coverage column and details in the HTML report, but I would like to see it in the terminal output as well.
Furthermore, the
primary_coverage :branch
setting - which I thought is the solution - does not seem to have any impact for me whatsoever. Not sure what is it supposed to do (and I have looked through all the pieces of Simplecov code that refers to it).My top of the
spec_helper.rb
file looks like this:Additional context
Simplecov required and working at the top of
spec_helper.rb
No rake. Directly running rspec, on a non rails app
No
0.22.0
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) +YJIT [x86_64-linux]
The text was updated successfully, but these errors were encountered: