被测试的class是VINESNodeAddressCollector:
@RunWith(PowerMockRunner.class)
//add following VINESNodeAddressCollector.class will make coverage not work, so comment out.
@PrepareForTest({ApplicationRunner.class
/*, VINESNodeAddressCollector.class*/})
@PowerMockIgnore ({"org.apache.log4j.*", "org.apache.commons.logging.*", "org.xml.sax.*"})
网上搜到的答案:http://stackoverflow.com/questions/9726212/why-tclemma-doesnt-coverage-code-with-tests-with-runwithpowermockrunner-class
AFAIK eclEmma, as well as many other coverage systems, modify your .class files to add coverage instructions. Most of these tools do that at "compile time", not at run time.
PowerMock instead, as well as AspectJ LTW and many other systems, manipulate the same bytecode but at "run time":
PowerMock is a framework that extend other mock libraries such as EasyMock with more powerful capabilities. PowerMock uses a custom classloader and bytecode manipulation to enable mocking of static methods, constructors, final classes and methods, private methods, removal of static initializers and more.
I have a similar problem with both eclEmma (various versions) and Cobertura in combination with AspectJ LTW, cause when the runtime modification of .class files happen, it somehow corrupts the modification done previously by the coverage tool.
I don't have yet found a solution, but at least found the symptom.
The right solution would be to debug PowerMock instrumentation and find out where and how it breaks coverage tools. It's quite a problem, for a testing tool, to break coverage tools, since the two are quite often used together
分享到:
相关推荐
Coverage.Tests.ps1
Learn how to write R code with fewer bugs. The problem with programming is that you are always one typo away from writing something silly. Likewise with data analysis, a small mistake in your model ...
开源项目“quii-learn-go-with-tests”是一个旨在教授Go语言编程的教程,它通过编写测试来引导学习者。这个项目的核心理念是实践是学习编程的最好方式,特别是在理解Go语言特性和最佳实践方面。"Hello, world"是编程...
org.junit.runners.AllTests.class org.junit.runners.BlockJUnit4ClassRunner.class org.junit.runners.JUnit4.class org.junit.runners.Parameterized.class org.junit.runners.ParentRunner.class org.junit....
测试在文件coverage-tests.js中指定。 每种语言都有一个文件夹,其中应包含该语言的发射器,模板和替代。 示例: : 在特定的SDK存储库中,应该有一个具有package.json的coverage-tests文件夹,该文件夹具有@...
1. boson.sniffer.practice.tests.v5.34 CCNA资源;
Kotlin多平台库提供显式类型(Kotlin multiplatform library providing explicit types.,) 说明:Kotlin多平台库提供显式类型。, (Kotlin multiplatform library providing explicit types.,) ....run/JVM tests.run
Example2.Diagnostics.Tests.ps1
.run/All tests.run.xml (941, 2023-12-19) .run/Check API binaries.run.xml (950, 2023-12-19) .run/Documentation.run.xml (958, 2023-12-19) .run/Dump API binaries.run.xml (948, 2023-12-19) .run/JS tests....
TestsRunningInCleanRunspace.Tests.ps1
PesterState.Tests.ps1
InModuleScope.Tests.ps1
Mock.Tests.ps1
SetupTeardown.Tests.ps1
Context.Tests.ps1
BreakAndContinue.Tests.ps1
Pester.Tests.ps1