简体   繁体   English

不生成 jacoco-ut.exec 覆盖率报告

[英]Not generate jacoco-ut.exec coverage report

Java 1.8. Java 1.8。 Maven 3.8. Maven 3.8。 I want to generate coverage report of junit tests.我想生成 junit 测试的覆盖率报告。 So I use this in my pom.xml所以我在我的 pom.xml 中使用它

                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.4.201502262128</version>
                        <executions>
                            <execution>
                                <id>prepare-ut-agent</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco-ut.exec</destFile>
                                    <propertyName>jacoco.agent.ut.arg</propertyName>
                                    <append>true</append>
                                </configuration>
                            </execution>
                            <execution>
                                <id>prepare-it-agent</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                                    <propertyName>jacoco.agent.it.arg</propertyName>
                                    <append>true</append>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

Open terminal and run test like this:打开终端并像这样运行测试:

mvn test -Dtest=com.my_company.myproject.ComponentServiceTest

Tests success finish.测试成功结束。 But coverage report to generate.但要生成覆盖率报告。 File jacoco-it.exec is not exist in target folder目标文件夹中不存在文件jacoco-it.exec

The pom.xml is missing the report goal as mentioned in the comment by @rajani-b . pom.xml缺少@rajani-b评论中提到的report目标。

Here is the configuration for the report goal.这是report目标的配置。

<execution>
  <id>report</id>
  <goals>
    <!--
      Generate coverage reports in xml,csv,html formats
      in folder ${project.build.directory}/site/jacoco
    -->
    <goal>report</goal>
  </goals>
</execution>

Below is the complete <plugin> section for jacoco-maven-plugin for reference.以下是jacoco-maven-plugin的完整<plugin>部分供参考。

<plugin>
   <groupId>org.jacoco</groupId>
   <artifactId>jacoco-maven-plugin</artifactId>
   <version>0.7.4.201502262128</version>
   <executions>
      <execution>
         <id>prepare-ut-agent</id>
         <phase>process-test-classes</phase>
         <goals>
            <goal>prepare-agent</goal>
         </goals>
         <configuration>
            <propertyName>jacoco.agent.ut.arg</propertyName>
            <append>true</append>
         </configuration>
      </execution>
      <execution>
         <id>prepare-it-agent</id>
         <phase>pre-integration-test</phase>
         <goals>
            <goal>prepare-agent</goal>
         </goals>
         <configuration>
            <propertyName>jacoco.agent.it.arg</propertyName>
            <append>true</append>
         </configuration>
      </execution>
      <execution>
         <id>prepare-agent</id>
         <goals>
            <goal>prepare-agent</goal>
         </goals>
      </execution>
      <execution>
         <id>report</id>
         <goals>
            <!--
              Generate coverage reports in xml,csv,html formats
              in folder ${project.build.directory}/site/jacoco
            -->
            <goal>report</goal>
         </goals>
      </execution>
   </executions>
</plugin>

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

相关问题 maven jacoco 插件不生成覆盖率报告 - maven jacoco plugin does not generate coverage report 使用 Gradle 将多个 JaCoCo.exec 文件聚合到单个覆盖率报告中 - Aggregate several JaCoCo .exec files into a single Coverage report with Gradle 需要使用jacoco.exec文件生成代码覆盖率报告 - Need to generate Code Coverage Reports using jacoco.exec file 如何将Maven项目Jacoco覆盖率报告专家告知xml,Jacoco执行 - how to intellij maven project jacoco coverage report expert to xml, jacoco exec Jacoco仅针对单个测试类生成覆盖率报告 - Jacoco generate coverage report for only a single test class Gradle:如何使用 jacoco 生成集成测试的覆盖率报告 - Gradle : How to generate coverage report for Integration test using jacoco 使用gradle生成单个单元测试的Jacoco代码覆盖率报告 - Generate Jacoco code coverage report for individual unit tests using gradle 在 jacoco 覆盖率报告中排除文件夹 - Exclude folder in jacoco coverage report 了解 JaCoCo 覆盖率 XML 报告 - Understanding the JaCoCo coverage XML report 带有 Jacoco 插件的 build.gradle 不会为集成测试生成覆盖率报告 - build.gradle with Jacoco plugin doesn't generate coverage report for integration tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM