我只尝试了spock测试,并获得“无法实例化规范'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'
}
}
关于testing - 无法实例化规范 'KernelTest',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29142377/