This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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();
Joined: Jun 19, 2008
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.