This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Testing and the fly likes Running JUnit against TomCat server from Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Running JUnit against TomCat server from Ant" Watch "Running JUnit against TomCat server from Ant" New topic
Author

Running JUnit against TomCat server from Ant

Anthony Bull
Greenhorn

Joined: Nov 08, 2004
Posts: 8
Hi, I have a bunch of j-unit tests I have written, half of which have to be run from my TomCat server (integration style tests). In my build script I am deploying my WAR to the TomCat server.

My question is, is it possible to get Ant to run these j-unit tests on the running TomCat server using the <junit> task? I don't want to go down the route of Cactus or something, as the tests that require TomCat running are designed to be full integration tests where the environment is setup as a production environment.

Cheers,

Ants.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
No, you can't do that with the <junit> task unless you write your own TestRunner implementation that contacts your application running on Tomcat and sends it a list of class names to execute as JUnit tests.

Effectively, you'd be reinventing Cactus...


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Anthony Bull
Greenhorn

Joined: Nov 08, 2004
Posts: 8
Originally posted by Lasse Koskela:
No, you can't do that with the <junit> task unless you write your own TestRunner implementation that contacts your application running on Tomcat and sends it a list of class names to execute as JUnit tests.

Effectively, you'd be reinventing Cactus...


Ok, I know how to get my build script to kick my unit testing off on the TomCat server - all I need to know is - can I somehow log the results of the unit tests and then get my build script to generate a report based on those? And also fail or email a failure message based on the results?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Again, Cactus would do this (collect test results) for you. I know that Cactus is a bit of a pain to set up but once you've done that, it should be a relatively smooth ride (compared to writing your own).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running JUnit against TomCat server from Ant