尽管很明显,这个展示了一个使用powermock和jacoco的解决方案,但我一直无法使它在一个相当简单的项目()中工作。
在我的例子中,测试正确执行,但是jacoco.exec文件丢失了,所以jacoco不检查覆盖率。
测试类:
@RunWith(PowerMockRunner.class)
@PrepareOnlyThisForTest(Util.class)
@PowerMockIgnore("org.jacoco.agent.rt.*")
public class UtilTest {
@Test
public void testSay() throw
当使用PowerMock和Mockito来存根和测试私有方法时,如果我们像这样包含任何带有@PrepareForTest({ AccountClientService.class })的类,AccountClientService.java中的所有方法都不会显示任何覆盖范围。尝试了堆栈溢出建议的各种方法,比如on the fly,offline instrumentatations和@Rule public PowerMockRule rule = new PowerMockRule(),仍然没有成功。不同版本的试验和错误。我的POM如下所示: 4.0.0 com.codependent.j
我添加了一些代码,用于在运行mvn clean install sonar:sonar.Only声纳相关功能时使用sonar.But生成jacoco覆盖报告,executed.Jacoco覆盖报告未生成。
<!-- Below plugin ensures the execution of test cases during maven build -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
当我在我的项目和由maven运行的测试中使用黄瓜、maven-surefire-plugin、maven-故障安全插件和jacoco时,我得到了这个错误。
有人能帮我解决这个问题吗?
org.sonar.java.jacoco.JacocoController$JacocoControllerError: Looks like several tests executed in parallel in the same JVM, thus coverage per test can't be recorded correctly.
at org.sonar.java.jacoc