Hello.. I spent a few hours trying to get Line Execution Count to be added to the report (as specified in this issue:
https://github.com/jacoco/jacoco/issues/89).
I was unable to get the correct amount of times a line gets executed.
I used this project as the template to run my test:
The resulting numbers were like this:
https://github.com/nenick/android-gradle-templateThis is a method inside my MainActivity.java file.
```
public void testFunc() {
intCOV 2 intMIS 0 brCOV 0 brMIS 0 int myvar = 1 + 1;
intCOV 7 intMIS 0 brCOV 2 brMIS 0 for(int i=0; i < 11; i++) {
intCOV 10 intMIS 0 brCOV 0 brMIS 0 System.out.println("Count is: " + i);
intCOV 4 intMIS 0 brCOV 0 brMIS 0 int more = myvar + i;
}
```
intCOV means instructions covered, brCOV means branches covered, MIS means missed..
Well I have one test inside of my AppUnitTests (MainActivityTests.java) file which calls the method activity.testFunc() (actually the code is view.testFunc()).
so it looks like the code 'int myvar = 1 + 1' is just one line that should have a coverage count of 1, but the instruction coverage is 2... its like that for all other pieces of code...
So this leads me to believe that Jacoco counts instructions... is there any way to also collect the line being executed (what instructions are on the same line --> they would mutually increment the line count by 1)
Or is this impossible? Could someone give a small reason why this is 'out of scope' or so hard to implement? Is it just the way that jacoco is designed that it is impossible to collect the line exe count?
Many thanks
By the way, the above report was made with this small change to jacoco:
```
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java
@@ -103,6 +103,13 @@ final class SourceHighlighter {
final String lineId = "L" + Integer.toString(lineNr);
final ICounter branches = line.getBranchCounter();
+ final ICounter instructions = line.getInstructionCounter();
+ pre.span().text(
+ "intCOV " + Integer.toString(instructions.getCoveredCount()) +
+ " intMIS " + Integer.toString(instructions.getMissedCount()) +
+ " brCOV " + Integer.toString(branches.getCoveredCount()) +
+ " brMIS " + Integer.toString(branches.getMissedCount())
+ );
```
My final question is, is there a way in the code to get "How many instructions are in the current ILine from within the Source Highlighter (or anywhere else in the code.) ? Does such a thing exist in the code?
If I can get the # of instructions in a line, I can divide the amount of covered instructions by the # of instructions per line to get the line execution count.
many thanks