Groovy 斯波克抛出一个错误,我可以';我似乎不明白

Groovy 斯波克抛出一个错误,我可以';我似乎不明白,groovy,junit,spock,Groovy,Junit,Spock,java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException位于 org.spockframework.runtime.JUnitSupervisor.error(JUnitSupervisor.java:92) 在 org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:318) 在 org.spockframe

java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException位于 org.spockframework.runtime.JUnitSupervisor.error(JUnitSupervisor.java:92) 在 org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:318) 在 org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:297) 在 org.spockframework.runtime.BaseSpecRunner.runSpec(BaseSpecRunner.java:90) 在 org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:81) 位于org.spockframework.runtime.Sputnik.run(Sputnik.java:63) org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 在 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

我有一个调用方法的简单测试用例

def 'some test for empty Lists'(){
        setup:
        List<Object> clauses=new ArrayList<Object>()

        when:
        String someString=builder.buildString(clauses, "someName", "AND");

        then:
        noExceptionThrown()
        someString==""
    }
def“空列表的一些测试”(){
设置:
列表子句=新的ArrayList()
什么时候:
String someString=builder.buildString(子句“someName”、“AND”);
然后:
noException抛出()
someString==“”
}
假设生成器是通过spring注入的。我搞不懂为什么会这样。这种情况只发生在少数测试用例中


非常感谢您的帮助:)我将spock 0.6与groovy 1.8结合使用。

我在使用一个简单的Eclipse java项目进行spock测试时遇到了与以下版本相同的错误:

  • spock-core-1.0-groovy-2.3
  • junit-4.12
只有当测试失败时才会抛出异常,但对于成功的测试是有效的

我发现这是一个Junit版本兼容性问题。我使用junit-4.7解决了这个问题,并测试了以下版本:

  • junit-4.6=>ok
  • junit-4.5=>ok
  • junit-4.4=>ko
  • junit-4.0=>ko

希望它有帮助

我在试图运行STS:3.6.4和jbossdeveloper Studio版本中的spock时遇到了同样的兼容性问题:
7.1.1.GA

使用
junit-4.7
而不是
junit-4.12

其他说明可在带有jUnit 4.12的spock 1.0解决方案中找到 当我将hamcrest-core-1.3添加到我的测试类路径中时,错误就消失了

出了什么问题? 我观察到了问题中描述的相同错误,但我设法让spock 1.0 groovy 2.4使用junit-4.12

问题是junit-4.12依赖于hamcrest。
实际上,
org.junit.internal.AssumptionViolatedException
实现了
接口
org.hamcrest.selfdescription

在每个测试过程中都会发生吗?它是否仅在使用
noExceptionSprown
语句时发生?