Closed rillig closed 11 months ago
Hi @rillig
Current implementation outputs the condition details of which are covered and not covered.
if(a>0 && a<100) {
print "something"
}
gobco
gives output as 4 (true and false)branches for 2 conditions(a>0 and a<100) like below in json output
{
"Start": "file.go:30:4",
"Code": "a>0",
"TrueCount": 2,
"FalseCount": 0
},
{
"Start": "file.go:30:11",
"Code": "a<100",
"TrueCount": 1,
"FalseCount": 2
},
Can I find branch coverage (not condition coverage) from your output?
Please help me to find whether edge cases are covered or not?
Hi @visu-suganya, as you already guessed, gobco
does not really provide branch coverage but instead condition coverage, despite its name. Up to now, I didn't need branch coverage, as I could tell from the missing conditions what parts of the code are still uncovered. Do you actually need the branch coverage, or is it merely a feeling of "the program is named gobco, so it should report branch coverage"? What use case do you have that requires branch coverage but not condition coverage?
@rillig Thanks for the immediate reply. I need branch coverage result so that developers can easily fix when compared to condition coverage.
In branch coverage, only 2 outcomes totally but in condition coverage, need to cover all the 4 outcomes(it will be difficult to cover all in development period). So Firstly I need to achieve branch coverage as first step and then go for condition.
Hi @rillig Is there any possibility to get C1(branch coverage) output?
To get C1 output, you can change the method instrumenter.markConds
by removing the branches for *ast.UnaryExpr
and *ast.BinaryExpr
. If that generates the output that you expect, I'll include it in the next release.
@rillig Thanks for the implementation and please release the implemented feature so that I can use it. Thanks a lot.
I don't have plans to add this feature anymore. In the past few years I didn't have a need for it.
The comments on this issue are generally off-topic, they are not about finding out which tests cover which code, but about implementing branch coverage in addition to condition coverage.
Assuming that gobco would output which test covers which condition, it would be possible to answer questions like the following:
Implementation ideas:
int
for performance.