Feature request: @Name

Behrang Saeedzadeh <[email protected]> Sun, 10 Jul 2011 10:38:04 +1000
Newsgroups gmane.comp.java.junit.devel
Message-ID <CAERAJ+8UK9XBTbME0Z7ACMUx3OL48v5V8EPk-6JcdKuq+vefvg@mail.gmail.com>
Hi,

I think it would be nice if there was an annotation for JUnit for
naming annotations.

Right now creating test cases with self explanatory names lead very
long and ugly methods names, e.g.:

@Test
public void headingElementShouldNotBeResolvedWithoutNamespaceMapping() {
}

@Test
public void headingElementShouldBeResolvedWithNamespaceMapping() {
}

It would be nice if we could have named the test case in an annotation, e.g.:

@Test
@Name("Heading Element Should Not Be Resolved Without Namespace Mapping")
public void testResolution1() {
}

@Test
@Name("Heading Element Should Be Resolved With Namespace Mapping")
public void testResolution2() {
}

or maybe even:

@Test(name = "Heading Element Should Not Be Resolve Without Namespace Mapping")
public void testResolution1() {
}

@Test(name = "Heading Element Should Be Resolved With Namespace Mapping")
public void testResolution2() {
}

Right now I have started using a similar annotation for my new
projects, but had it been integrated with JUnit, it would have used
the name in reporting errors, etc.

A @Description element might also be useful for providing more details
about a test.

Cheers,
Behrang Saeedzadeh
http://www.behrang.org

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2