0

I have unit tests that generate runnable classes with a main class, compiles them and execute them as part of the test with Runtime.getRuntime().exec("java", "-cp", ..., "Main", ...) or new ProcessBuilder("java", "-cp", ..., "Main", ...).start().

Although these main classes cover a lot of the project, the code coverage they represent is invisible to jacoco and the covered code doesn't appear in the report.

I saw that the jacoco report ran with a javaagent.

-javaagent:C:\\Users\\myusername\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.8\\org.jacoco.agent-0.8.8-runtime.jar=destfile=C:\\Users\\myusername\\git\\project\\target\\jacoco.exec

What happens when I propagate that javaagent to the jvm started by Runtime.exec(...) or ProcessBuilder(...).start() ?

Runtime.getRuntime().exec("java", "-javaagent:...", "-cp", ..., "Main", ...) or new ProcessBuilder("java", "-javaagent:...", "-cp", ..., "Main", ...).start().

Does it override the running jacoco report ? What I want to do instead is take into consideration the parts of the code covered by the main I execute.

Sybuser
  • 735
  • 10
  • 27

0 Answers0