这曾经有用:
从Eclipse内部,选择一个Spock规范,其中包含一个(spock)模拟或存根,然后选择Run as - > JUnit测试。
突然间我不能再运行这些了,但得到了java.lang.VerifyError。
当运行没有任何模拟/存根的规范时,它按预期工作,当从Gradle构建运行时,这不会发生。
这是我在Eclipse中使用存根运行Spec时得到的堆栈跟踪:
java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter overrides final\
method visit.(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;\
[Ljava/lang/String;)V
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at net.sf.cglib.core.AbstractClassGenerator.<init>(AbstractClassGenerator.java:38)
at net.sf.cglib.core.KeyFactory$Generator.<init>(KeyFactory.java:127)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:112)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(ProxyBasedMockFactory.java:80)
at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:49)
at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:51)
at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:47)
at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:282)
at org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:131)
at se.hd.taglib.TaglibSpecBase.stubPageContext(TaglibSpecBase.groovy:43)
我没有为运行配置设置任何参数(因为我以前不需要),但是我可以在运行配置中设置一些运行时或环境变量来解决这个问题吗?
org.spockframework:spock-core:0.7-groovy-2.0
org.codehaus.groovy:groovy-all:2.0.6
Version: Juno Service Release 1 Build id: 20121004-1855
,(在jdk1.7.0_06.jdk上运行,但源级别设置为1.6)2.7.1.xx-RELEASE-20121219-0800-e42
答案 0 :(得分:3)
听起来你的Eclipse类路径有错误的CGLIB(或ASM)版本。 Spock 0.7是针对cglib:cglib-nodep:2.2.2
编译的。