我正在关注this文章,使用Powermock为jacoco工作。在使用eclemma的eclipse中,我能够看到正确的代码覆盖率。但是我们使用声纳测量代码覆盖范围更大。
为了生成送入声纳的jacoco报告,我们通过VM args诱导了jacoco代理。蚂蚁目标运行单元测试以生成报告。
这些是我的VM参数:
-Xmx1048m -Xms1048m -XX:PermSize=512M -XX:MaxPermSize=1024M
-javaagent:<somepath>\powermock-module-javaagent-1.6.1.
jar
-javaagent:<somepath>\jacocoagent.jar=
destfile=<somepath>\jacoco.exec,append=true,excludes=
com.google.*:com.sun.*:-Org.mockito.*:-Org.junit.*:
-Org.apache.*:junit.*,includes=*
-Ddeployed.server.type="tomcat" -noverify
在文章之后,我还将powermock代理放入javaoptions但我收到的错误
java.lang.NoClassDefFoundError: org/powermock/core/transformers/impl/MainMockTransformer
FATAL ERROR in native method: processing of -javaagent failed
at org.powermock.modules.agent.PowerMockClassTransformer.<clinit>(PowerMockClassTransformer.java:41)
at org.powermock.modules.agent.PowerMockAgent.<clinit>(PowerMockAgent.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.ClassNotFoundException: org.powermock.core.transformers.impl.MainMockTransformer
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)