| Author |
Designating test category - Functional Tests with JUnit
|
Peter Pascale
Greenhorn
Joined: Jun 18, 2008
Posts: 1
|
|
We're trying to implement a JUnit-based solution that would allow us to designate a test as being a functional test, to be run as part of a functional test build on our integration server. Basically we need a way to tell unit tests apart from functional tests. We would rather not segregate the functional tests in a different directory structure. Instead we'd like something annotation-based if possible. The current thinking call for introduction of a custom Runner that identifies functional test based on a custom annotation. Then we can co-mingle unit and functional tests, not relying on directory segregation. This must be a common problem, yet I don't see a common solution. And even if we do go through the trouble of writing a custom Runner, how does one specify the use of that Runner in an ant <junit> execution?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26193
|
|
Peter, Welcome to JavaRanch! I assume you are using JUnit 4 since you are talking about annotations. If so, this extension supports a category annotation. TestNG does as well, but that's not JUnit.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Arup Kumar
Greenhorn
Joined: Jun 19, 2008
Posts: 5
|
|
Hey Peter, we are trying to achieve the same functionality. I was having two approaches. 1.)Using AnnotationRunner class, and getting Description d=annoRunner.getDescription();and based on the description which I assumed will reflect the Annotation tag, extract the Category and Run'em sequentially. 2.) I wanted to register the Categories as Listner's and execute it using a sample like.. JUnitCore core= new JUnitCore(); //Result result= new JUnitCore().runMain(args); //RingingListener ring=new RingingListener();
|
 |
Arup Kumar
Greenhorn
Joined: Jun 19, 2008
Posts: 5
|
|
Currently its possible to add @Category ("A") to a junit test. and get to run the test case based on Category A, with the following lines of code, which is adapted from the CategoryFilterTest class of Junit-ext 0.24. JUnitCore core = new JUnitCore(); Request req = Request.aClass(ACategoryTest.class); Runner r=req.getRunner(); setCategoryValue("A"); core.run(req.filterWith(new CategoryFilter(getCategoryValue()))); We would like to ask if someone is working on a way to assign multiple categories like @Category("A", "B", "C") //Above line is just a conceptual representation, not possible syntactically. to add such kind of a category to a junit test and easily get those multiple categories. Also, it would be nice to have a functionality in Ant to specify the category of test cases we want to run in the <junit> task. If this has not been done, I guess we may take the initiative to provide this.
|
 |
 |
|
|
subject: Designating test category - Functional Tests with JUnit
|
|
|