【发布时间】:2021-07-06 21:46:49
【问题描述】:
我正在为我的测试类使用 PowerMockito 和 @PrepareForTest 注释。当我这样做时,Sonar 说没有一个分支被覆盖。但是,我的其他不使用 PowerMockito 的测试类运行良好。这是我的 pom 的样子
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.2 </version>
<scope>test</scope><plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<!-- <phase>prepare-package</phase> -->
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</dependency>
我需要在这个 pom 中添加什么吗? 任何帮助表示赞赏,在此先感谢
【问题讨论】:
-
Powermockito 不适用于 Sonar。请参阅:stackoverflow.com/questions/27925401/… 和 stackoverflow.com/questions/28087791/…
标签: java spring-boot sonarqube