Re: Alternate @Category annotations

Dale Emery <[email protected]> Tue, 28 May 2013 11:06:35 -0700
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
Hi Kristian,

> We have received a patch over at maven-surefire (https://jira.codehaus.org/browse/SUREFIRE-833) that allows any annotation to be used as a replacement for @Category(mycategory.class). So you basically can make your own @IntegrationTest annotation.
> 
> I am sceptical to the patch in question, one reason being that it blows standardized tool 
> support out of the water. Is there any "conformant" way this can be implemented ?

One possibility (that I'm toying with an another domain) is to use a meta-annotation like @CategoryAnnotation.  Any annotation that is itself annotated with @CategoryAnnotation is a category annotation.

So you could declare:

@CategoryAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface IntegrationTest {}

Then you could mark any test:

@IntegrationTest
@Test
public void myIntegrationTest() { … }

Perhaps @CategoryAnnotation would require its target to take a few parameters, such as a description.

These meta-annotations can be slightly dizzying for some programmers, but they sure make the test annotations cleaner

Of course, for this to work, the framework would have to recognize @CategoryAnnotation and its meaning.

Dale

--
Dale Emery
Consultant to software teams and leaders
http://dhemery.com



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/junit/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/junit/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/