I've been attempting, without any luck, to get server-side JUnit tests to test my EJB3 code in-container using the new, annotation-style JUnit 4 tests. I'm using the Ant 1.7 to deploy my code and run my tests, as this version has JUnit 4 functionality built in. I attempted to use both JUnitEE and Cactus to run my tests.
I was successfully able to get JUnitEE to run JUnit 3.8 style tests, but the various permutations of configurations I tried using JUnit 4 failed to work. I tried with and without the JUnit4TestAdapter in a suite() method. I was getting different depending on the setup I was using. If I have the opportunity later, I'll post the errors I was getting and the setups. However, I did try various things to no avail.
My attempts to get cactus working seemed to meet with more success, and the tests do run. However, I am skeptical as to whether my setup is actually running the tests from the sever, and not on the local box. The reason I say that is that when I forgot to package some jars that were necessary to the build, the ant tests still ran and passed. However, when I used the cactus servlet to run the tests manually, they would fail.
Here's the relevant section of my ant script for my cactus tests. Note, it's pretty messy at the moment, as the goal was more to get things working than to have a clean final script.
<!-- Create the war file -->
<!-- todo: build actual war for actual app; then have cactified copy -->
<!-- Run the tests -->
<!-- todo: do integration tests instead, once this is working -->
Cactus JUnit test failures
Beginning (re)deployment of servlet at ${webserver.tests.url}
Waiting for servlet to be undeployed...
Unable to undeploy previous servlet
Waiting for servlet to be deployed...
Unable to deploy servlet
Any help I could get concerning this would be most appreciated. Google, and searching various java forums hasn't turned up anything useful. For that matter, just letting me know if you've had similar difficulties, or no difficulties with the same task would be useful, as it'd give a hint as to whether I'm missing something obvious. Thanks.