-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Jaoco does not count branch for conditionals with early returns. #313
Comments
I just tested you snipped with JaCoCo: It does show two branches on the line in question.
Here some background information can be found how JaCoCo probes work: http://www.eclemma.org/jacoco/trunk/doc/flow.html |
Hi, Marc I am using 0.7.4.201502262128 Zhi On Wed, May 20, 2015 at 3:56 PM, Marc R. Hoffmann notifications@github.com
Zhi Han |
I run your code snippet with EclEmma (the JaCoCo Eclipse plugin) and it shows two branches for the line. How did you test??? |
I actually write my own code to use the jacoco core to report. So It might be that I have made a mistake. But given the instrumented bytecode here, could you explain which probe should be associated with the two branches? In this example, there are three probes in total, all inserted before the return statements. The second branch at :20 has probe 2 (:28) and 3 (:35) associated with it. Probe 1 (:12) needs to be associated with the first branch (:4). But neither probe 2 or 3 should be associated with the branch at :4. I cannot see a right answer unless there is fourth probe inserted at :14. |
If you use the API this expression should give you 2 for the respective line:
Probes always needs to be inserted before a return statement. See documentation: http://www.eclemma.org/jacoco/trunk/doc/flow.html
|
Thanks. I see the issue now.
|
Here is a simple chunk of Java code.
Jacoco inserts three probes, each for the return arguments. Then the first if condition is only associated with probe 0. And then the tool does not recognize it as a branch. The instrumented Java bytecode is attached below.
The text was updated successfully, but these errors were encountered: