用于组件测试的Jacoco插件

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

我的项目结构是这样的

myProject
    app
        module1
            submodule
            pom.xml
        pom.xml
    automation
        component-tests
        pom.xml
    pom.xml
pom.xml

使用Jacoco maven插件对覆盖率进行评分。

组件测试模块仅包含测试文件夹没有任何源。测试是简单的单元测试,运行应用程序并在引擎盖空手道框架下运行,该框架运行微服务的完整组件测试。

现在运行测试后 - 我看到每个模块都包含 jacoco.exec 文件,常规模块具有覆盖范围,但是组件测试具有 jacoco.exec 但没有有关覆盖范围的数据,不知何故它不执行所有模块代码的检测。

我怀疑是因为这个模块没有源码。我尝试使用包含 - 并没有真正帮助,因为我认为它在模块的范围内工作。

下面是maven的surefire论证

javaagent:/Users/me/.m2/repo/org/jacoco/org.jacoco.agent/0.8.10/org.jacoco.agent-0.8.10-runtime

当我运行组件测试模块时,是否有任何选项可以计算整个项目的覆盖率?

<profiles>
<profile>
  <id>coverage</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.11</version>
        <executions>
          <execution>
            <id>generate-jacoco-coverage</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <propertyName>surefireArgLine</propertyName>
            </configuration>
          </execution>
          <execution>
            <id>jacoco-report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>
<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <argLine>
          ${surefireArgLine}
        </argLine>
      </configuration>
    </plugin>
java maven unit-testing jacoco jacoco-maven-plugin
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.