On Monday, October 29, 2018 at 10:41:02 AM UTC+1, [email protected]
wrote:
>
> ok.. so is there any other way to create the jacoco.exec file if i am not
> using jacocagent while executing the junit from command line..
Execution of JUnit with coverage is not different from execution of any
other Java application with coverage, so for simplicity I will demonstrate
last one.
Given "src/Example.java":
class Example {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Compile:
$ mkdir classes
$ javac -g src/Example.java -d classes
Then you have two distinct options.
First and recommended - on-the-fly instrumentation with agent:
$ java -cp classes -javaagent:jacoco-0.8.2/lib/jacocoagent.jar Example
Hello, World!
Second - offline pre-instrumentation without agent:
$ java -jar jacoco-0.8.2/lib/jacococli.jar instrument classes --dest
instrumented
[INFO] 1 classes instrumented to /private/tmp/example/instrumented.
$ java -cp instrumented:jacoco-0.8.2/lib/jacocoagent.jar Example
Hello, World!
In both cases by default "jacoco.exec" is created in current directory.
About customizations please read:
https://www.jacoco.org/jacoco/trunk/doc/agent.html
or
https://www.jacoco.org/jacoco/trunk/doc/offline.html
respectively.
Generation of report using CLI:
$ java -jar jacoco-0.8.2/lib/jacococli.jar report jacoco.exec --classfiles
classes --sourcefiles src --html report
[INFO] Loading execution data file /private/tmp/example/jacoco.exec.
[INFO] Analyzing 1 classes.
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/72a95ab5-6311-4544-a0bd-4b8ebfb7d277%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.