简体   繁体   中英

Jacoco Show Source Code

I have some code which reads the exec file and creates html pages for all of my projects running on a webspehre server. The server is on a remote machine, I have all the source code running on the remote machine copied to my local machine. I need to know how, with the html file generated and the exec file how I can view the source code.

Is this even possible?

To successfully create coverage reports with Jacoco from Maven you should add the jacoco maven plugin to your POM.

As explained on the Jacoco Maven Plugin page you need to add the plugin (with the latest version as of this posting):

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.7.6-SNAPSHOT</version>
</plugin>

And then you need to add extra configuration to tell jacoco what phase to instrument tests and then when to generate the reports

This configuration was taken from one of the example jacoco pom s for a JAR project that runs JUnit tests under code coverage and creates a coverage report (target/site/jacoco/index.html).

 <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.6-SNAPSHOT</version>
    <executions>
      <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>
            <!-- implementation is needed only for Maven 2 -->
            <rule implementation="org.jacoco.maven.RuleConfiguration">
              <element>BUNDLE</element>
              <limits>
                <!-- implementation is needed only for Maven 2 -->
                <limit implementation="org.jacoco.report.check.Limit">
                  <counter>COMPLEXITY</counter>
                  <value>COVEREDRATIO</value>
                  <minimum>0.60</minimum>
                </limit>
              </limits>
            </rule>
          </rules>
        </configuration>
      </execution>
    </executions>
  </plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM