java jacoco maven插件未报告测试覆盖率
我试着用jacoco和maven。当我运行mvn clean测试时,我希望覆盖率输出会写入目标/覆盖率报告,但是当我打开索引时。html在构建之后,它是空的
我检查了以下内容, -杰科科。exec文件存在,其中包含一组类名 -在coverage html中有一个链接“Sessions”,当我点击它时,我会看到一堆似乎已经执行的类 -我在运行maven命令时没有看到错误或警告
我不明白为什么报告是空的。从我看到的所有例子来看,这似乎应该是可行的。我错过了什么
我正在为maven插件使用以下jacoco配置
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
<skip>false</skip>
<excludes/>
<outputDirectory>${project.build.directory}/coverage-reports/</outputDirectory>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<includes>
<include>mypackage.*</include>
</includes>
<check>false</check>
</configuration>
<executions>
<execution>
<id>pre-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-test</id>
<goals>
<goal>report</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
更新
显然,这与我提供的includes模式有关。当我删除“包含”时,它确实显示了覆盖范围,但超出了我的需要。我仍在努力找出合适的包含模式
# 1 楼答案
你也需要把它挂到surefire上,换成