sampig / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Support @ExtensionAnnotation as meta-annotation #382

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have a suite of Geb tests that consists of read-only and read-write tests, 
and I need to be able to specify whether to run mutating tests. I can use 
@Requires for this, but I have to repeat my condition for each class or method. 
I would like to be able to use @Requires/@IgnoreIf as a meta-annotation to 
define my own annotation, which has the condition baked in.

Original issue reported on code.google.com by christop...@artsquare.com on 9 Dec 2014 at 12:10

GoogleCodeExporter commented 8 years ago
This should already be possible with Groovy's `@AnnotationCollector`.

Original comment by pnied...@gmail.com on 9 Dec 2014 at 12:18

GoogleCodeExporter commented 8 years ago
If it is, that's a transform I don't know how to use, and I think my use case 
(essentially, test profiles) is a common one. Could the docs get an example?

Original comment by christop...@artsquare.com on 9 Dec 2014 at 12:25

GoogleCodeExporter commented 8 years ago
It's a Groovy feature, and you should find plenty of information on the web.

Original comment by pnied...@gmail.com on 9 Dec 2014 at 12:26

GoogleCodeExporter commented 8 years ago
(We welcome contributions to http://docs.spockframework.org.)

Original comment by pnied...@gmail.com on 9 Dec 2014 at 12:28

GoogleCodeExporter commented 8 years ago
I've looked over the docs for @AnnotationCollector, and it appears to me that 
it pushes the definition for the values off to the class that's finally 
annotated, meaning that it can't be used for the intended goal of specifying 
the condition closure in one spot.

Original comment by christop...@artsquare.com on 9 Dec 2014 at 12:34

GoogleCodeExporter commented 8 years ago
Values can be specified on the original annotation or collector annotation. 
Both is supported.

Original comment by pnied...@gmail.com on 9 Dec 2014 at 2:09

GoogleCodeExporter commented 8 years ago
@Requires and @IgnoreIf can't be meta-annotated on a collector annotation 
because their Targets don't include ANNOTATION. My naive attempt at providing a 
default "value" in the Groovy annotation produced compile errors (in the 
GRECLIPSE compiler) because the parser was apparently unable to figure out how 
to compile a Groovy '@interface'.

Original comment by christop...@artsquare.com on 9 Dec 2014 at 7:54

GoogleCodeExporter commented 8 years ago
Thanks for the feedback. I'll see what we can do to make @AnnotationCollector 
work with Spock annotations.

Original comment by pnied...@gmail.com on 13 Dec 2014 at 1:36

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 1 Mar 2015 at 11:45