New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on @TestFor annotation #801

Closed
claudiocarcaci opened this Issue Jan 2, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@claudiocarcaci

claudiocarcaci commented Jan 2, 2018

Since the last commit 635401d on https://github.com/spockframework/spock/commits/master

I have the following error within the execution of my tests:

java.lang.annotation.IncompleteAnnotationException: org.spockframework.runtime.model.FieldMetadata missing element initializer
	at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
	at com.sun.proxy.$Proxy14.initializer(Unknown Source)
	at org.spockframework.runtime.SpecInfoBuilder.buildFields(SpecInfoBuilder.java:103)
	at org.spockframework.runtime.SpecInfoBuilder.doBuild(SpecInfoBuilder.java:64)
	at org.spockframework.runtime.SpecInfoBuilder.build(SpecInfoBuilder.java:49)
	at org.spockframework.runtime.Sputnik.getSpec(Sputnik.java:82)
	at org.spockframework.runtime.Sputnik.runExtensionsIfNecessary(Sputnik.java:90)
	at org.spockframework.runtime.Sputnik.run(Sputnik.java:61)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
	at org.gradle.internal.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:109)
	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

The error is raised by SpecInfoBuilder.buildFields() method.

In particular when metadata is working on FieldMetadata which references @TestFor(https://github.com/grails/grails-core/blob/3.2.x/grails-plugin-testing/src/main/groovy/grails/test/mixin/TestFor.java) annotation it fails with the exception reported above.

I'm executing the test on Grails service. I need the snapshot version of the library because this fix #762 is mandatory for us in order to solve some issues with constructors that have the same method signature.

In order to reproduce the issue is enough:

  1. Create a Grails 3.2.0 project
  2. Import the library testCompile "org.spockframework:spock-core:1.2-groovy-2.4-SNAPSHOT" within build.gradle
  3. Write a scratchy test on a Grails service (e.g. EmptyService) like
import grails.test.mixin.TestFor
import spock.lang.Specification

@TestFor(EmptyService)
class ScratchySpec extends Specification {
	void "Do the right thing"() {
		expect:

		assert true
	}
}

System information:

Framework: Grails 3.2.0
Java version: 1.8.0_31
Groovy version: 2.4
Gradle version: 3.0
Ubuntu 16.04
testCompile "org.spockframework:spock-core:1.2-groovy-2.4-SNAPSHOT"

TY

@leonard84

This comment has been minimized.

Show comment
Hide comment
@leonard84

leonard84 Jan 2, 2018

Member

Are you sure that the tests are compiled and run with the same version of Spock? Does it work for Specs (without @TestFor) with fields in your Project?

Member

leonard84 commented Jan 2, 2018

Are you sure that the tests are compiled and run with the same version of Spock? Does it work for Specs (without @TestFor) with fields in your Project?

@claudiocarcaci

This comment has been minimized.

Show comment
Hide comment
@claudiocarcaci

claudiocarcaci Jan 3, 2018

Hi Leonard,
Yes, I put a breakpoint at runtime and the spock library used is the one specified within the testCompile directive.

Other tests (written using Spock) without the @TestFor annotation work properly.

claudiocarcaci commented Jan 3, 2018

Hi Leonard,
Yes, I put a breakpoint at runtime and the spock library used is the one specified within the testCompile directive.

Other tests (written using Spock) without the @TestFor annotation work properly.

@leonard84

This comment has been minimized.

Show comment
Hide comment
@leonard84

leonard84 Feb 12, 2018

Member

@claudiocarcaci have you tried if the recent change fixed the problem?

Member

leonard84 commented Feb 12, 2018

@claudiocarcaci have you tried if the recent change fixed the problem?

@claudiocarcaci

This comment has been minimized.

Show comment
Hide comment
@claudiocarcaci

claudiocarcaci Feb 13, 2018

I saw the update now.

I've tried to run the test by recompiling the library with this change reverted 982e8dd

The test fails with the above exception as expected.

Then I have re-imported the library "org.spockframework:spock-core:1.2-groovy-2.4-SNAPSHOT" and the test run without errors.

So, the bug has been fixed!
Thank you very much for the support.

claudiocarcaci commented Feb 13, 2018

I saw the update now.

I've tried to run the test by recompiling the library with this change reverted 982e8dd

The test fails with the above exception as expected.

Then I have re-imported the library "org.spockframework:spock-core:1.2-groovy-2.4-SNAPSHOT" and the test run without errors.

So, the bug has been fixed!
Thank you very much for the support.

@leonard84 leonard84 closed this Feb 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment