无法实例化规范 'KernelTest'
Failed to instantiate spec 'KernelTest'
我只尝试spock测试,得到"Failed to instantiate spec 'KernelTest'",here是我的完整代码
以下是我的代码:
// build.gradle
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.9'
compile gradleApi()
testCompile 'junit:junit:+'
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3'
}
我的测试是:
// KernelTest.groovy
package ro.gd
class KernelTest extends spock.lang.Specification {
def 'test smth'() {
expect: 1 == 1
}
}
提高:
ro.gd.KernelTest > initializationError FAILED
org.spockframework.util.InternalSpockError
Caused by: java.lang.ExceptionInInitializerError at KernelTest.groovy:-1
Caused by: groovy.lang.GroovyRuntimeException at KernelTest.groovy:-1
如果我将 ro/build.gradle
更改为使用特定版本的 groovy,我可以让它与最新的 gradle 一起使用:
compile 'org.codehaus.groovy:groovy-all:2.3.9'
然后将ro-gd/build.gradle
的依赖改成:
dependencies {
compile gradleApi()
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3', {
exclude module: 'groovy-all'
}
}
我只尝试spock测试,得到"Failed to instantiate spec 'KernelTest'",here是我的完整代码
以下是我的代码:
// build.gradle
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.9'
compile gradleApi()
testCompile 'junit:junit:+'
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3'
}
我的测试是:
// KernelTest.groovy
package ro.gd
class KernelTest extends spock.lang.Specification {
def 'test smth'() {
expect: 1 == 1
}
}
提高:
ro.gd.KernelTest > initializationError FAILED
org.spockframework.util.InternalSpockError
Caused by: java.lang.ExceptionInInitializerError at KernelTest.groovy:-1
Caused by: groovy.lang.GroovyRuntimeException at KernelTest.groovy:-1
如果我将 ro/build.gradle
更改为使用特定版本的 groovy,我可以让它与最新的 gradle 一起使用:
compile 'org.codehaus.groovy:groovy-all:2.3.9'
然后将ro-gd/build.gradle
的依赖改成:
dependencies {
compile gradleApi()
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3', {
exclude module: 'groovy-all'
}
}