I'm writing my first Gradle plugin. The default build works fine, including a small number of unit tests. I'm now trying to set up an integration test infrastructure, using nebula.test.
I created an empty integration test class, along with settings in my build.gradle to configure the "integTest" task and related sourcesets and dependencies. I used several examples on the net and existing plugins on github to guide me.
Before I show my code, this is the error I get:
groovy.lang.MissingPropertyException: No such property: setupMethod for class: org.spockframework.runtime.model.SpecInfo Possible solutions: setupMethods
Here's my "build.gradle" file:
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
apply plugin: 'groovy'
apply plugin: 'java-gradle-plugin'
apply plugin: 'maven'
repositories {
mavenCentral()
jcenter()
maven { url "http://oss.sonatype.org/content/repositories/releases/" }
maven { url "http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot" }
maven { url "http://nexus.opendaylight.org/content/repositories/opendaylight.release" }
}
dependencies {
compile "org.codehaus.groovy:groovy-all:2.3.9"
compile gradleApi()
compile "org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT"
compile "org.opendaylight.yangtools:binding-java-api-generator:0.7.0-SNAPSHOT"
compile "org.opendaylight.yangtools:binding-generator-api:0.7.0-SNAPSHOT"
compile "org.opendaylight.yangtools:binding-generator-impl:0.7.0-SNAPSHOT"
compile "commons-io:commons-io:2.4"
testCompile("org.spockframework:spock-core:1.0-groovy-2.3") {
exclude group: "org.codehaus.groovy"
}
}
sourceCompatibility = 1.7
group = 'com.att.opnfv.yang'
version = '1.0.0-SNAPSHOT'
sourceSets {
integTest {
groovy.srcDir file("src/integTest/groovy")
resources.srcDir file("src/integTest/resources")
}
}
dependencies {
integTestCompile sourceSets.main.output
integTestCompile configurations.testCompile
integTestCompile sourceSets.test.output
integTestRuntime configurations.testRuntime
testCompile( 'com.netflix.nebula:nebula-test:2.2.0' ) {
exclude module: 'groovy-all'
}
}
task integTest(type: Test) {
testClassesDir = sourceSets.integTest.output.classesDir
classpath = sourceSets.integTest.runtimeClasspath
}
check.dependsOn -= integTest
And here's my simple integration test spec (I added the one "def" after the first try, which made no difference):
import nebula.test.IntegrationSpec
class YangPluginIntegSpec extends IntegrationSpec {
def 'simple'() {
writeHelloWorld("com.example")
}
}
Update:
Here's the complete stacktrace for the error.
groovy.lang.MissingPropertyException: No such property: setupMethod for class: org.spockframework.runtime.model.SpecInfo Possible solutions: setupMethods at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51) at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227) at com.energizedwork.spock.extensions.TempDirectoryInterceptor.install(TempDirectoryExtension.groovy:92) at com.energizedwork.spock.extensions.TempDirectoryInterceptor$install.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at com.energizedwork.spock.extensions.TempDirectoryExtension.visitFieldAnnotation(TempDirectoryExtension.groovy:21) at com.energizedwork.spock.extensions.TempDirectoryExtension.visitFieldAnnotation(TempDirectoryExtension.groovy) at org.spockframework.runtime.ExtensionRunner.doRunAnnotationDrivenExtensions(ExtensionRunner.java:100) at org.spockframework.runtime.ExtensionRunner.runAnnotationDrivenExtensions(ExtensionRunner.java:65) at org.spockframework.runtime.ExtensionRunner.runAnnotationDrivenExtensions(ExtensionRunner.java:60) at org.spockframework.runtime.ExtensionRunner.runAnnotationDrivenExtensions(ExtensionRunner.java:51) at org.spockframework.runtime.ExtensionRunner.run(ExtensionRunner.java:41) at org.spockframework.runtime.Sputnik.runExtensionsIfNecessary(Sputnik.java:88) at org.spockframework.runtime.Sputnik.getDescription(Sputnik.java:55) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:83) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)
I then tried stepping through this code in the debugger. I was able to hit the breakpoint at AbstractCallSite.callGetProperty(), line 227. It hit this breakpoint several dozen times in my test case. I also set a breakpoint at GetEffectivePojoPropertySite.getProperty(), line 63, but for some reason it never hits that breakpoint.
The "callGetProperty()" method looks like this:
public Object callGetProperty(Object receiver) throws Throwable {
return acceptGetProperty(receiver).getProperty(receiver); // 227
}
That method looks like this:
public final Object getProperty(Object receiver) throws Throwable {
try {
return effective.getProperty(receiver); // line 61
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre); // line 63
}
}
As line 63 is in a catch clause, I also set a breakpoint on line 61, and that breakpoint is never hit either.
Update:
Another interesting point is the TempDirectoryInterceptor.install() method one call up the stacktrace:
@Override
void install(SpecInfo spec) {
spec.setupMethod.addInterceptor this // line 92
spec.cleanupMethod.addInterceptor this
}
There's the "setupMethod", but I don't know what that's supposed to be. A breakpoint set on this line does not get hit.