Repository navigation
Closed
Milestone
Description
After merging #694 this issue is here to keep track of the functionality until initial release and helps me & others :)
Big thanks to @som4ik @tycooon @stepozer @klyonrad and many others for their valuable contributions!
- Merge initial PR Feature/branches coverage support #694
- Merge corresponding html formatter PR Add ability to support branch coverage statistics ruby >= 2.5 simplecov-html#64
- Address remaining code review feedback
- Make sure problems with existing PR are solved (ref1 ref2)
- parallel tests support works as intended
-
:nocov:blocks should be considered
- Address initial code review comments
- Change used option name to use branch coverage/chanege coverage type
- add some feature tests
- for instance with the neat tester script
- Investigate coverage reporting (it seems like it reports lines as covered when what we'd like to have are branches)
- release pre release version for general/public testing (this and formatter)
- make it possible that the branch coverage percentage is displayed as the "main" coverage and all our checks take it instead of line coverage
- also allow people to do coverage checks versus multiple metrics for instance I want my line coverage to be at least 95% and my branch coverage to be at least 90%.
- figure out problems with the format data is stored in Release Branch coverage #781
- fix reported beta problems
- release the "finished for now" branch coverage
Reacted by Somar Melkhem, Yuri Smirnov, Luka Lüdicke, Andrii Gladkyi, Dmitry Polushkin, Dominik Sander, Shimba, Koji, Rafał W, Rustam Ibragimov, Nikita Esaulov and 4 more
Reacted by Henrich Moraes
Metadata
Metadata
Assignees
Labels
No labels
Activity
PragTob commentedon Dec 15, 2019
👋
Hi @som4ik - got around to writing a feature test for this. It seems to me (and my reading of the code) that we still report coverage on a per line basis - is this correct from your memory? 😅
What I mean by that is that we use branch coverage to figure out which lines are covered and then we mark those lines as covered and report them as such. I think what we want is that we report it on a per branch basis (so instead of 80/100 lines covered we wanna say 33/38 branches covered or something to the tune of this).
Confirmation would be nice!
som4ik commentedon Dec 16, 2019
Hi @PragTob 👋


As I remember per line bases report is mandatory-default coverage report, passing
:branchesparameter toCoverage.startadds a new type of collected coverage result matrics, but doesn't cancel generating per line bases report.Just to clarify, we don't use per line bases to generate branch coverage metrics, you can notice that the coverage report displays already your suggestion:
let me guess what made it confusing:
use_branchable_reportit should be at leastadd_branchable_report.Hope I answered the question 😄
PragTob commentedon Dec 16, 2019
Yeah you did thank you, then I just gotta tweak the cukes and selects on all of that. Thank you!
PragTob commentedon Dec 21, 2019
Yeah so I took a look at it and figured out that right now we basically just "add" branch coverage but there's no way to make it the "main coverage" aka the coverage by we fail if we say minimum coverage or something else.
I think I want to do a first release with that, but I think it'd be good if people could decide what their "main coverage" would be (and then also display that most prominently).
Another thing that my tests just showed me as counter intuitive is that if a file has no conditional statements at all there are no branches and hence we report 0 branches and say it's 100% covered even if no method defined in there is ever covered. Which is plenty weird I believe. On the other hand branch coverage by itself can't determine whether it's covered or not as the coverage data is literally empty...
if anyone here had input on these points I'd appreciate it.
edit: did my bunch of reading, and apparently that's how branch coverage is supposed to work. Curious because entire files could be not covered and one would never know. Maybe that's edge coverage, online resources aren't really generous about code coverage sadly.
JonJagger commentedon Dec 28, 2019
I agree that does sound weird. Rather than thinking of branches being "off" the main trunk you could think simply of there being N different branches. N different paths. From that point of view, a file with some code which has no conditional statements doesn't have zero branches, it has one path.
Maybe changing the vocabulary will help?
Eg Use the word 'covered' in line messages.
Eg Use the word 'taken' or 'visited' in branch/path messages?
P.S. Awesome work. Can't wait to add this.
JonJagger commentedon Dec 29, 2019
Some code that previously had 100% coverage just dropped to 99% coverage. Looking at the html report it shows this:

I don't understand how line 42 can have no coverage when it is a
whileand the block it controls 43-46 does have coverage (24 hits). My only guess is it's something to do with the previous line, 41, which has an && in it, and the forthcoming branch coverage?PragTob commentedon Dec 29, 2019
@JonJagger 👋
That seems unlikely, doesn't look like you have branch coverage activated (there would be little badges saying "+", 0 or something around there or something).
I absolutely agree the line should be covered though, so that seems odd. But it reminds me off #764 where it was a coverage bug that some until line wasn't covered.
Are you sure that this is related to some simplecov upgrade or maybe some ruby version upgrade in the middle of it?
tleish commentedon Dec 29, 2019
@JonJagger - out of curiosity, what does the coverage for
def same?look like?JonJagger commentedon Dec 29, 2019
The coverage for

def sameisJonJagger commentedon Dec 29, 2019
Yes. Sorry. I was not clear. My assumption was that my recent upgrade had got a new version of simplecov which had been refactored in preparation for the branch-coverage.
The app in question is docker containerized. It gets simplecov and ruby from a base image (Alpine).
Shelling into that I can see the Gemfile.lock
And ruby -v gives
The previous docker image gives...
and
I will build a new image with the previous version of simplecov and report back...
The code being covered has not changed.
JonJagger commentedon Dec 29, 2019
Rebuilding with simplecov set to 0.16.1 the coverage anomaly goes away...

I note also that ruby -v gives 2.5.7p206
PragTob commentedon Dec 29, 2019
@JonJagger could you please open a separate issue as it seems to be not connected to this then? Also the ruby version changes so that's still my suspect but it could ofc still be that 0.17.0/0.17.1 broke something.
JonJagger commentedon Dec 29, 2019
I am now unable to reproduce the anomaly locally with simplecov set to 0.16.1, 0.17.0, 0.17.1
However I am still getting the same coverage anomaly on images built on my CI cloud-pipeline.
I will dig some more and if need be open a new issue.
PragTob commentedon Dec 29, 2019
@JonJagger maybe running tests in parallel? That makes things a lot fancier and more likely to have weird errors :)
14 remaining items
tycooon commentedon Jan 9, 2020
Unfortunately, this is not how Ruby branch coverage work. You could store the condition result in a variable
xand your code would look likereturn if x. So this is just 2 branches from ruby perspective.In case you care about branch coverage a lot, you should probably structure your code like so:
This way you can ensure that all combinations are covered.
tycooon commentedon Jan 9, 2020
No, because there are no conditionals in this code. Method
anymight be always returning42, who knows? Ruby is a dynamic language.PragTob commentedon Jan 10, 2020
@klyonrad yeah what @tycooon said :) Seems odd to me that the line is makred red though, I'd expect it to be green since it has line coverage (but missing branch coverage) - haven't looked into that yet but I might like it better this way either way :D
PragTob commentedon Jan 12, 2020
@klyonrad @deivid-rodriguez moved that issue to #820 and will try to chip away at it today as it's a rather critical bug.
Update Changelog with the latest and greatest #781
PragTob commentedon Jan 19, 2020
0.18.0.beta2 has been released, I'd be happy if y'all gave it another should have some really great improvements! https://github.com/colszowka/simplecov/blob/master/CHANGELOG.md#0180beta2-2020-01-19
PragTob commentedon Jan 23, 2020
has anyone tried out the beta2/beta3 releases? Would be happy about feedback!
klyonrad commentedon Jan 23, 2020
Not on a grand scale, only sometimes: It does not break 🎉 😍
The change in showing names and hit counts (!!) for the branch certainly makes it better. Although it starts to look funny when you have a lot (!) of branches in one line 🔱
Even in string interpolation things you can see the difference, or even more subtle (and mean) the nil check (
&.) operator!I will try to motivate my former team to test it in their project and report success or failure (the one where I tested over a year and reported issues)
PragTob commentedon Jan 25, 2020
@klyonrad thanks a bunch!
I might just go ahead and release it though (testing is great anyhow) but I figure that's the best way to get people to test it.
I haven't even tested it with
&.- probably should add a test case for that just for fun and profit.If you have ideas how to make multiple per one line more readable, your ideas are welcome. Off the top of my I'd say sort them by order of appearance (we have the start_col/end_col available) or maybe show more information on hover.
Thanks!
PragTob commentedon Jan 28, 2020
And 0.18.0 is released 🎉
Didn't manage to get in the display as "main coverage" but I don't think it's the main killer feature. There are some spots where we need to up support and they're in my head and I might/will make issues for them.
I figured it was more important to finally get this into everyone's hands so they can let me/us know what works and what doesn't.