0
votes

I'M trying to get the Code Coverage using JaCoCo-javaagent passing VM argument

-javaagent:/test/jacoco/jacocoagent.jar=destfile=/test/jacoco/jacoco.exec,includes=com.*,append=true

I'M able to get some value in jacoco.exec file but not able to get coverage report.How can i convert jacoco.exec to coverage report OR am i missing something in VM Argument.

Condition is like that i have only jar and war and using jBoss server to run application.

2

2 Answers

0
votes

Run SonarQube, which includes excellent JaCoCo reporting. No need to parse the binary output from JaCoCo yourself.

Links to instructions for running it with various tools, including the command line are here.

You'll need to run a sonar server. You can download it here. On a Mac, you can do

  1. brew install sonar
  2. sonar console

The commands for Maven, for example, are

  1. mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true
  2. mvn sonar:sonar
0
votes

You can generate JaCoCo report by using org.jacoco:jacoco-maven-plugin:report maven goal. For example:

pom.xml

...
<profiles>
  <profile>
    <id>jacoco-report</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.7.5.201505241946</version>
          <executions>
            <execution>
              <goals>
                <goal>prepare-agent</goal>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

After mvn -Pjacoco-report clean install jacoco maven plugin generate the report in target/site/jacoco directory.