Jacoco + tomcat = jacoco.exec, Zero Coverage Report. Help.

I have a web application deployed to Tomcat. Before I get more information, let me outline the versions.

Versions: jdk 1.7, Tomcat - 7.0.19, jacoco -0.5.6

I added jdk1.7 to Tomcat. In the file \ apache-tomcat-7.0.19 \ bin \ startup.bat I added.

SET JAVA_HOME=C:\ProgramFiles\Java\jdk1.7.0

I also added a jacoco agent for Tomcat. In apache-tomcat-7.0.19 \ bin \ catalina.bat I added.

SET JACOCO=-javaagent:<my download folder>\jacoco-0.5.6.201201232323\lib\jacocoagent.jar=destfile=C:\jacoco.exec,append=true,includes=* 
set JAVA_OPTS=%JAVA_OPTS% %JACOCO%

Now when I start Tomcat and hit my web applications, as expected, there is a C: \ jacoco.exec file.

Now I moved the code to the following directory structure jacoco.exec / bin / / coveragereport

Now I used the ReportGenerator class from http://www.eclemma.org/jacoco/trunk/doc/examples/java/ReportGenerator.java . I have a bunch of HTML reports in the / coveragereport directory. However, all code is displayed as unaffected. Although after I fired Tomcat, I went to http: // localhost : / and looked. I was hoping to get a coverage report.

I am missing something very elementary. Please help me.

+5
source share
3 answers

Tomcat will write the Jacoco file at shutdown.

+8
source

Alternatively, you can use the ant dump task :

jacoco:dump address="server.example.com" reset="true" destfile="remote.exec"/>

But for this you need to specify output mode tcpserverfor java agent .

-javaagent:[yourpath/]jacocoagent.jar=output=tcpserver,address=<host>,port=<port>,...
+5

6300 - . , , , netstat -an | grep "LISTEN"

+1

All Articles