Configuring JVM with javaagent

1,861 views
Skip to first unread message

sneha agarwal

unread,
Apr 13, 2015, 1:25:57 PM4/13/15
to jac...@googlegroups.com
Hello guys,

Can someone guide me as to what is the step by step process to configure the javaagent with the JVM. I am struggling with this from last 2 days and now am at my wits end.
Also, currently I have put JaCoCo as a plugin in my pom.xml. Do I need to download the Jacoco jar files separately to configure.

Regards 

Marc R. Hoffmann

unread,
Apr 13, 2015, 2:04:27 PM4/13/15
to jac...@googlegroups.com
Hi,

did you notice that JaCoCo comes with documentation?

http://www.eclemma.org/jacoco/trunk/doc/

Maybe you start with the working Maven example which is included:

http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom.xml

Regards,
-marc
--
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 jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAPExvo87BAzfJUFih8vE%3Dbs2MvPdYL0z%3DqhpwWwvLpFa5gdDTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

sneh...@gmail.com

unread,
Apr 14, 2015, 3:41:10 AM4/14/15
to jac...@googlegroups.com
Hi Marc,
Thank you for the quick response.
I did go through the doc and have created a pom which works fine for me but only for the local tests and not the source files which I am running in a different instance of tomcat.Can i do code coverage of the source files from the pom of my tests?
Details of the pom
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<configuration>
<append>true</append>

<destFile>${project.build.directory}/coverage/jacoco.exec</destFile>
<dataFile>${project.build.directory}/coverage/jacoco.exec</dataFile>
<!-- <tcpclient>127.0.0.1</tcpclient> <port>8080</port> -->

<outputDirectory>${project.build.directory}/coverage-reports/</outputDirectory>
<classDumpDir>${project.build.directory}/coverage-reports/</classDumpDir>
<excludes />
<skip>false</skip>
<includes>
<include>com/**</include>
</includes>
<!--<propertyName>surefireArgLine</propertyName>-->
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
<executions><!-- Prepares the property pointing to the JaCoCo runtime
agent which is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
<!-- <limit> <counter>LINE</counter> <value>COVEREDRATIO</value>
<minimum>0.60</minimum> </limit> -->
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
<limit>
<counter>CLASS</counter>
<value>MISSEDCOUNT</value>
<maximum>0</maximum>
</limit>
</limits>

</rule>

<rule>
<element>CLASS</element>
<!-- <excludes> <exclude>*Test</exclude> </excludes> -->
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
</limit>
</limits>
</rule>
</rules>
<!-- <target>
<report>
<executiondata>
<fileset dir="${project.build.directory}">
<include name="jacoco.exec" />
</fileset>

</executiondata>
</report>
</target> -->

</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<argLine>${jacoco.agent.argLine}</argLine>
<!-- <fork>true</fork> <forkmode>once</forkmode> -->

<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>

Marc R. Hoffmann

unread,
Apr 20, 2015, 6:59:56 AM4/20/15
to jac...@googlegroups.com
In this case you need to configure the JaCoCo agent for the tomcat
instance -- depends on how you launch it. Here you find general
information about the JaCoCo agent:

http://www.eclemma.org/jacoco/trunk/doc/agent.html

Regards,
-marc

sneha agarwal

unread,
Apr 20, 2015, 7:01:05 AM4/20/15
to jac...@googlegroups.com

Thank u Marc for all your help.
I was able to figure it out

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/axgXGwXPCXI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/5534DC2B.3060908%40mountainminds.com.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages