简体   繁体   English

Spock框架在模拟@component时抛出错误

[英]Spock framework throwing error while mocking a @component

I am using Spock with Spring and I am getting error while mocking one of my component class. 我将Spock与Spring结合使用,并且在模拟我的组件类之一时遇到错误。

Please find the below stack trace. 请找到下面的堆栈跟踪。 It has nothing more than this and I thus I am not able to proceed. 它仅此而已,因此我无法继续。 Versions: 版本:

  • cglib-nodep : 3.2.0 cglib-nodep:3.2.0
  • cglib : 3.2.0 cglib:3.2.0
  • spock-core : 1.0-groovy-2.4 spock-core:1.0-groovy-2.4
  • spring-test : 4.1.4.RELEASE 弹簧测试:4.1.4。发布

    java.lang.NoClassDefFoundError: Could not initialize class org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory$ConstructorFriendlyEnhancer 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:45) at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:281) at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:99) at TermsAndConditionsControllerAPISpec.setup(TermsAndConditionsControllerAPISpec.groovy:19) java.lang.NoClassDefFoundError:无法在org.spockframework.mock.runtime.ProxyBasedMockFactory $ CglibMockFactory.createMock(ProxyBasedMockFactory.java:80)处初始化类org.spockframework.mock.runtime.ProxyBasedMockFactory $ CglibMockFactory $ ConstructorFriendlyEnhancer。 org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:51)处的.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:49)在org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44 )在org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:45)在org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:281)在org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java: 99)在TermsAndConditionsControllerAPISpec.setup(TermsAndConditionsControllerAPISpec.groovy:19)

Not sure why this happened but I just removed cglib and it just worked. 不知道为什么会这样,但是我只是删除了cglib而已。 So final dependency list was : cglib-nodep : 3.2.0 spock-core : 1.0-groovy-2.4 spring-test : 4.1.4.RELEASE 所以最终的依赖项列表是:cglib-nodep:3.2.0 spock-core:1.0-groovy-2.4 spring-test:4.1.4.RELEASE

I am still not sure why this worked by removing cglib. 我仍然不确定为什么通过删除cglib可以起作用。 In case someone has a detailed reason for this please share. 如果有人对此有详细原因,请分享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM