简体   繁体   English

Jacoco Show源代码

[英]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. 我有一些代码可以读取exec文件并为在webspehre服务器上运行的所有项目创建html页面。 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. 我需要知道如何使用生成的html文件和exec文件查看源代码。

Is this even possible? 这有可能吗?

To successfully create coverage reports with Jacoco from Maven you should add the jacoco maven plugin to your POM. 为了使用Maven的Jacoco成功创建覆盖率报告,您应该将jacoco maven插件添加到POM中。

As explained on the Jacoco Maven Plugin page you need to add the plugin (with the latest version as of this posting): Jacoco Maven插件页面上所述,您需要添加插件(具有此发布的最新版本):

<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 然后,您需要添加额外的配置以告诉jacoco仪器测试应该进入哪个阶段,然后何时生成报告

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). 此配置来自一个JAR项目的示例jacoco pom ,该项目在代码覆盖率下运行JUnit测试并创建覆盖率报告(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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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