可以使用 mvn Surefire:test 命令创建 jacaco 报告聚合吗?

问题描述 投票:0回答:0

这是我的pom:

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.10</version>
  <executions>
    <execution>
      <id>prepare-unit-tests</id>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
      <configuration>
        <destFile>${basedir}/target/jacoco.exec</destFile>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>report-aggregate</id>
            <phase>test</phase>
            <goals>
                <goal>report-aggregate</goal>
            </goals>
        </execution>
        <execution>
            <id>merge-results</id>
            <phase>test</phase>
            <goals>
                <goal>merge</goal>
            </goals>
            <configuration>
                <fileSets>
                    <fileSet>
                        <directory>${code.coverage.project.folder}</directory>
                        <includes>
                            <include>**/jacoco.exec</include>
                        </includes>
                    </fileSet>
                </fileSets>
                <destFile>${code.coverage.overall.data.folder}/aggregate.exec</destFile>
            </configuration>
        </execution>
    </executions>
</plugin>

当我使用命令 mvn clean test 时,报告已成功生成,但当我使用 mvn initializesurefire:test 时,生成的报告百分比为零。使用 mvn Surefire:test 是否无法成功生成报告?

maven jacoco
© www.soinside.com 2019 - 2024. All rights reserved.