Generating Report with JUnit Launcher

94 views
Skip to first unread message

Thijs Nulle

unread,
Dec 1, 2020, 9:51:54 AM12/1/20
to JaCoCo and EclEmma Users
I want to be able to create Jacoco reports based on the tests run with the JUnit launcher. Is there a way to generate a report only based on the JUnit launcher?
I am currently using the Instrumenter class to generate a source file for a class that I'd want to test, however, there does not seem to be a way to add this to the JUnit launcher when running it. 
The only way I have found in the examples on the API is that the class for which the reports can be generated have to implement the Runnable interface but this will not be possible, so is this step necessary for getting the eventual data in the ExecutionDataStore?
From what I can imagine it must be possible since it is essentially the same as how for example IntelliJ would generate its reports. Is there any direction I should be looking for information, examples etc.? 

Evgeny Mandrikov

unread,
Dec 16, 2020, 11:03:09 AM12/16/20
to JaCoCo and EclEmma Users
Instrumenter can instrument any class, there is no such requirement that classes should implement Runnable. Usage of Runnable is just convenient in this particular example to execute instrumented classes.

Since you wanna use JUnit launcher for execution, then the best persons to advice about how to pass instrumented classes to JUnit launcher, are probably developers of JUnit.

Also maybe instead of instrumenting classes by yourself, you can simply use JaCoCo agent - https://www.jacoco.org/jacoco/trunk/doc/agent.html ?
To obtain ExecutionDataStore from file produced by agent you can use ExecFileLoader - https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecFileLoader.html
Reply all
Reply to author
Forward
0 new messages