I am writing an autograder and will need to be able to measure the coverage of tests provided by a student. To use the JaCoCo Java API, I am working with the provided
CoreTutorial, which has a
Runnable inner class
TestTarget, containing two methods:
run() and
isPrime(). The code instruments the class, then calls the
run() method. (I'm omitting some details.) It works, reporting partial coverage. This is in branch
jacoco1 of my repo.
I created another branch
jacoco2 that splits
TestTarget into two classes:
ClassUnderTest (which has
isPrime()) and
TestClass (which has
run()). It compilies and runs without throwing any exceptions, but it does not report any coverage. The
differences between the two versions are minimal. (The reason I put them in different branches is so it is easy to see the
diff on GitHub.)
Could anyone tell me what I am doing wrong and how to correctly adapt CoreTutorial to involve multiple classes, where one calls the other?
I've appended additional the output of each program.
Thank you.
Ellen
Output of run on jacoco1 (original CoreTutorial)
Coverage of class com/spertus/jacquard/coverage/CoreTutorial$TestTarget
2 of 25 instructions missed
1 of 4 branches missed
1 of 7 lines missed
0 of 3 methods missed
1 of 5 complexity missed
Line 40: green
Line 41:
Line 42:
Line 43: green
Line 44: green
Line 45:
Line 46:
Line 47: green
Line 48: yellow
Line 49: red
Line 50:
Line 51:
Line 52: green
Output of run on jacoco2 (split CoreTutorial)
Coverage of class com/spertus/jacquard/coverage/CoreTutorial$ClassUnderTest
20 of 20 instructions missed
4 of 4 branches missed
5 of 5 lines missed
2 of 2 methods missed
4 of 4 complexity missed
Line 53: red
Line 54:
Line 55: red
Line 56: red
Line 57: red
Line 58:
Line 59:
Line 60: red