在我的示例 Maven 项目中,我有这个 jacoco 配置:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
我从https://automationrhapsody.com/automated-code-coverage-of-unit-tests-with-jacoco-and-maven/获得的(然后更改为最新版本)
它适用于实现的覆盖率(src/main),但没有给我任何测试本身的覆盖率信息(src/test)
尽管我同意这是一个合理的默认设置,但我想将其更改为我的项目之一,以告诉我测试的覆盖率信息。有人知道怎么做吗?
我在这里有一个完整的例子。https://github.com/alex028502/jacoco-example