Jan 20, 2017

[memo] How to use jacoco

Here is my configuration of pom.xml







"jacoco-initialize" prepare jacoco-agent before "test" maven lifecycle. And "jacoco-site" export report in "package" maven lifecyccle phase.

mvn clean package
You can see the report in ${your_project_root_directory}/target/site/jacoco/index.html

I learned how to use jacoco from here.
http://www.javaworld.com/article/2074515/core-java/unit-test-code-coverage-with-maven-and-jacoco.html

If you use maven-surefire-plugin and argLine, you would see "Skipping JaCoCo execution due to missing execution data file......" message and failed to create report. Please refer the official document of jacoco.
http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html

If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo.
One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation:

org.apache.maven.plugins
maven-surefire-plugin

@{argLine} -your -extra -arguments


Here is my real configuration pom.xml

No comments: