[
https://jira.codehaus.org/browse/SUREFIRE-833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=322161#comment-322161
]
Paul Sprague edited comment on SUREFIRE-833 at 3/19/13 10:50 AM:
-----------------------------------------------------------------
Attaching a second patch that builds on the 1st:
Most class level annotations on a test class are now able to be used within
surefire's groups/excludedGroups configuration properties. Annotations are
added recursively so that annotations of annotations are supported. Annotations
within java.lang.annotation and org.junit.experimental.categories.Category are
excluded.
*Example of how this works:*
{code:java}
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@interface AnnotationParent {}
@AnnotationParent
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface AnnotationA {}
@AnnotationParent
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface AnnotationB {}
// No parent annotation
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface AnnotationC {}
@AnnotationA
class ATest {}
@AnnotationB
class BTest {}
@AnnotationC
class CTest{}
// No Annottion
class NTest{}
{code}
*Some possible includes/excludes using surefire:*
{code:xml}
<!-- Run A,B only -->
<groups>my.pkg.AnnotationA, my.pkg.AnnotationB</groups>
<!-- or -->
<groups>my.pkg.AnnotationParent</groups>
<!-- Run C,N only -->
<excludedGroups>my.pkg.AnnotationA, my.pkg.AnnotationB</excludedGroups>
<!-- or -->
<excludedGroups>my.pkg.AnnotationParent</excludedGroups>
{code}
was (Author: spraguep):
Attaching a second patch that builds on the 1st:
Most class level annotations on a test class are now able to be used within
surefire's groups/excludedGroups configuration properties. Annotations are
added recursively so that annotations of annotations are supported. Annotations
within java.lang.annotation and org.junit.experimental.categories.Category are
excluded.
*Example of how this works:*
{code:java}
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@interface AnnotationParent {}
@AnnotationParent
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface AnnotationA {}
@AnnotationParent
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface AnnotationB {}
// No parent annotation
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface AnnotationC {}
@AnnotationA
class ATest {}
@AnnotationB
class BTest {}
@AnnotationC
class CTest{}
// No Annottion
class NTest{}
{code}
*Some possible includes/excludes using surefire:*
{code:xml}
// Including/Excluding tests using surefire/failsafe
// Run A,B only
<groups>my.pkg.AnnotationA, my.pkg.AnnotationB</groups>
or
<groups>my.pkg.AnnotationParent</groups>
// Run C,N only
<excludedGroups>my.pkg.AnnotationA, my.pkg.AnnotationB</excludedGroups>
or
<excludedGroups>my.pkg.AnnotationParent</excludedGroups>
{code}
> Support for annotated JUnit @Category
> -------------------------------------
>
> Key: SUREFIRE-833
> URL: https://jira.codehaus.org/browse/SUREFIRE-833
> Project: Maven Surefire
> Issue Type: Improvement
> Components: Junit 4.x support
> Affects Versions: 2.12
> Reporter: Jan Goyvaerts
> Fix For: 2.15
>
> Attachments: SUREFIRE-833-spraguep-2.patch,
> SUREFIRE-833-spraguep.patch
>
>
> The current implementation of Surefire seems to look for explicit @Category
> annotations in the test classes. And will only consider those. Suppose I'd
> like to add a more concise annotation for this:
> @Category(IntegrationTests.class) <== JUnit @Category
> @Target({ElementType.TYPE})
> @Retention(RetentionPolicy.RUNTIME)
> @Documented
> public @interface IntegrationTest {}
> Annotating my test class with @IntegrationTest does not work. Although I
> think it looks much better than repeating everywhere in my code
> "@Category(com.foo.bar.IntegrationTests.class)". For which I add an
> additional dependency in the interface class btw.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira