-
Notifications
You must be signed in to change notification settings - Fork 571
Add method coverage support #987
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
base: main
Are you sure you want to change the base?
Add method coverage support #987
Conversation
9851ba0 to
5987457
Compare
|
@PragTob hope you will find some time to review the changes. |
5987457 to
9a8b324
Compare
|
Hey @PragTob, maybe you can take a look now? |
|
@PragTob ping! |
1 similar comment
|
@PragTob ping! |
2ce910b to
54684e8
Compare
54684e8 to
8ede952
Compare
33cbb8e to
574b45c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this PR, it would make a welcome inclusion 🙏
I am curious - would method coverage improve coverage support for ruby 3's endless methods?
I have found that endless methods currently show as covered if they are never executed by tests.
Even if you have branching coverage enabled they report as fully covered.
Example class, spec and coverage report follow.
Note that uncovered_endless_method shows as covered despite not being executed by the test.
Whereas endless_branching_method shows branching coverage failing since it was executed.
I would have expected uncovered_endless_method to show as partially covered.
class CoveragePoc
# this method is fully covered
def self.simple_method
:simple
end
# the :b branch for these methods is not covered
def self.endless_branching_method(arg) = arg ? :a : :b
def self.branching_method(arg)
arg ? :a : :b
end
# these methods are not covered at all
def self.uncovered_endless_method = :uncovered_endless
def self.uncovered_method
:uncovered
end
endRSpec.describe CoveragePoc do
it 'works' do
expect(described_class.simple_method).to eq(:simple)
expect(described_class.branching_method(true)).to eq(:a)
expect(described_class.endless_branching_method(true)).to eq(:a)
end
end|
Hey @amatsuda, maybe you could take a look? I know there are conflicts, but I don't want to fix them in case there are no plans to merge this PR anytime soon. |
|
@tycooon Thank you for working on this! Yes, I'm very much interested in this feature, and willing to take a look once the patch is cleanly rebased against the main branch :) |
c2e0130 to
c59387a
Compare
|
Hey @amatsuda, I just updated the branch 👍 |

See #782.
Also addresses #801 and #916.
Support for HTML formatter can be found here: simplecov-ruby/simplecov-html#110.
Some notes:
ResultSerializationmodule).ResultMergeroptimizations :( Now it's operatingResultobjects, however it still parses and merges files one be one.lines: []instead of"lines" => []), just the same way you get it when calling Ruby'sCoverage.result. Because of that, a lot of specs were updated.0x0000000000000000.adapt_pre_simplecov_0_18_resultlogic was moved toResultSerialization.deserialize. Also old-style branch info is supported (evalis still used for that).All this stuff has been battle-tested on a couple of big projects, some of which merge results of multiple CI jobs.