这曾经有效:
在 Eclipse 中,选择其中包含 (spock) 模拟或存根的 Spock 规范,然后选择 Run as -> JUnit Test。
突然我不能再运行这些了,但是得到一个 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
- Eclipse:
Version: Juno Service Release 1 Build id: 20121004-1855
,(在jdk1.7.0_06.jdk上运行,虽然源级别设置为1.6) - Groovy-Eclipse 插件:
2.7.1.xx-RELEASE-20121219-0800-e42