On Thursday, July 11, 2019 at 2:06:02 PM UTC+2, [email protected]
wrote:
>
> Hi,
>
> Thanks. I tried setting the agent in tcpserver mode and fetch the exec
> file using the dump CLI command. But when I try to fetch the report using
> cli, get the below error.
>
> Configuration:
>
>
> -javaagent:jacoco-0.8.4\lib\jacocoagent.jar"=port=9005,output=tcpserver,address=*
>
> dump command:
> java -jar jacoco-0.8.4\lib\jacococli.jar dump --port 9005 --destfile
> C:\Dhivya\jacoco\jacoco-11july.exec
>
This command writes to file "C:\Dhivya\jacoco\jacoco-11july.exec", but next
command uses file "jacoco-client.exec" Why?
> Report Command:
>
> java -jar jacoco-0.8.4\lib\jacococli.jar report jacoco-client.exec
> --classfiles MyRest\target\classes\com\infor\m3\MyRest\excel\* --html
> jacoco\html-tomcat\ --name cc-report
>
This command also has "\*" (backslash character followed by star character)
at the end of value for "--classfiles" parameter. Why?
Your directory "MyRest\target\classes\com\infor\m3\MyRest\excel"
for sure contains file "RefreshSheet.class"
let's say that it also contains file "Foo.class"
I'm pretty sure that in your command line interpreter aka shell this star
character causes command to be interpreted as
java -jar jacoco-0.8.4\lib\jacococli.jar report jacoco-client.exec
--classfiles MyRest\target\classes\com\infor\m3\MyRest\excel\Foo.class
MyRest\target\classes\com\infor\m3\MyRest\excel\RefreshSheet.class --html
jacoco\html-tomcat\ --name cc-report
So that
"jacoco-client.exec" is first value for "execfiles" parameter,
"MyRest\target\classes\com\infor\m3\MyRest\excel\Foo.class" is value for
"--classfiles" parameter,
"MyRest\target\classes\com\infor\m3\MyRest\excel\RefreshSheet.class" is
second value for "execfiles" parameter,
thus you get loading of two execution data files
> Error:
> [INFO] Loading execution data file
> C:\Users\dravichandran\eclipse-workspace\Jacoco\jacoco-client.exec.
> [INFO] Loading execution data file
> C:\Users\dravichandran\eclipse-workspace\MyRest\target\classes\com\infor\m3\MyRest\excel\RefreshSheet.class.
>
whereas las one is not execution data file and so you get corresponding
exception
> Exception in thread "main" java.io.IOException: Invalid execution data
> file.
> at
> org.jacoco.cli.internal.core.data.ExecutionDataReader.read(ExecutionDataReader.java:89)
> at
> org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
> at
> org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:73)
> at
> org.jacoco.cli.internal.commands.Report.loadExecutionData(Report.java:98)
> at org.jacoco.cli.internal.commands.Report.execute(Report.java:82)
> at org.jacoco.cli.internal.Main.execute(Main.java:89)
> at org.jacoco.cli.internal.Main.main(Main.java:104).
>
You don't need to specify "\*", because
value of "--classfiles" parameter can be a directory
and in this case all class files from this directory and all
sub-directories will be used.
So you can even use
"C:\Users\dravichandran\eclipse-workspace\MyRest\target\classes".
For example given following "Example.java" file in directory "src"
class Example {
public static void main(String[] args) {
System.out.println("Hello, World!");
while (true) ;
}
}
after compilation into directory "classes"
javac src\Example.java -d classes
execution of
java -javaagent:jacoco-0.8.4\lib\jacocoagent.jar=output=tcpserver -cp
classes Example
java -jar jacoco-0.8.4\lib\jacococli.jar dump --destfile jacoco.exec
java -jar jacoco-0.8.4\lib\jacococli.jar report jacoco.exec --classfiles
classes --sourcefiles src --html report
produces following report
[image: example.png]
--
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/989f9f44-6bad-4691-9fea-278dba3ab843%40googlegroups.com.