Spring boot SpringBoot2.4.4 Junit5和JaCoco测试覆盖率未显示
我正在使用junit5和springboot 2.4.4版本。我已经为测试覆盖率集成了jacoco。然而,我的测试通过了,但它没有显示覆盖率 在这里,我将介绍一个演示类,介绍我实现的概念Spring boot SpringBoot2.4.4 Junit5和JaCoco测试覆盖率未显示,spring-boot,junit5,jacoco,Spring Boot,Junit5,Jacoco,我正在使用junit5和springboot 2.4.4版本。我已经为测试覆盖率集成了jacoco。然而,我的测试通过了,但它没有显示覆盖率 在这里,我将介绍一个演示类,介绍我实现的概念 public class Calculator { public int sum() { return sumPrivate(); } private int sumPrivate() { return 100; } } 这是它的测试类 public class Calcu
public class Calculator {
public int sum() {
return sumPrivate();
}
private int sumPrivate() {
return 100;
}
}
这是它的测试类
public class CalculatorTest {
@Test
public void test() {
assertNotNull(new Calculator().sum());
}
}
我已经调试了我的类私有方法get,但没有在jacoco代码覆盖率中显示
这是我的插件配置
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${maven.test.skip}</skip>
<argLine>${argLine}</argLine>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipITs}</skip>
<argLine>${argLine}</argLine>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<configuration>
<skip>${maven.test.skip}</skip>
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
maven surefire插件
真的
单元测试
测试
测试
${maven.test.skip}
${argLine}
**/*IntegrationTest.java
集成测试
集成测试
测试
${skippits}
${argLine}
**/*IntegrationTest.java
org.jacoco
jacocomaven插件
0.8.6
${maven.test.skip}
${basedir}/target/coverage reports/jacoco-unit.exec
${basedir}/target/coverage reports/jacoco-unit.exec
文件
真的
jacoco初始化
配制剂
杰科科遗址
验证
报告