我想知道Scala的一些单元测试和Java的源代码(测试和代码在不同的包中)的代码覆盖率是多少,当我运行Jacoco报告时,它显示只有4%的代码覆盖率。
当我查看报告时,它显示了我为许多文件创建测试的0%。我怀疑单元测试没有被包含在报告中,可能是因为所有的测试类文件都在target/test-classes目录中。我尝试包含includeTests
标记,但没有任何效果。
下面是插件在pom中的样子:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<includeTests>true</includeTests>
<!--<includes>
<include>**/test-classes/**</include>
</includes>-->
<excludes>
<exclude>**/dto/**</exclude>
<exclude>**/exceptions/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
字符串
现在我已经注解掉了include
标签,因为如果我包含它,测试编译为0个类。否则我怎么能包含target/test-classes目录?
很抱歉,如果这是一个简单的修复,我很新的单元测试和Jacoco。谢谢!
1条答案
按热度按时间cdmah0mi1#
这是我的个人设置。它有点乱,我仍然在工作的一些部分,但它为我工作。你可以试试这个。
字符串