I have a java junit test that passes when run alone on a development machine. We also have a hudson job which runs all the tests, invoked via ant, on a Mac OS X 10.4 node wi
I have multiple junit jars in my classpath. one is of ant and another is from WAS. As I removed that the error went away... Ant version that I am using 1.8
I faced the same issue. The problem was with byte code generation with mocking the Config class; We changed the import to
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
and it worked.
I believe I saw this error once when I ended up with multiple versions of junit on my classpath. Might be worth checking out.
This can occur when an uncaught RuntimeException is thrown. Unfortunately, the junit ant task doesn't output the exception so there isn't an easy way to determine the root cause. You can work around this by running the test case from the command line where the exception will be shown.
java <vm-args> org.junit.runner.JUnitCore <test-class-name>
In my case, an IllegalArgumentException was being thrown.
For me, it was an "java.lang.OutOfMemoryError" in the forked VM (junit task with fork="yes") which made this message appear in the main VM.
The OutOfMemory was visible in the ant log (well, is visible since it's still present).
I use ant 1.7.1, so no hope with upgrading ant.
After putting the same VM parameters in "Run>External tools>External tools>JRE" than in Eclipse.ini (-Xms40m -Xmx512m -XX:MaxPermSize=256M) the problem is solved.
I keep fork to "no" to be sure ant use the parameters.
In my case, the classpath that my tests were running on exceeded the maximum length of what was allowed by the Operating System for an environment variable (aka the Linux Classpath too long issue).
The solution was to create a pathing jar. Simplified steps:
Use jar (or your IDE) to make a jar of your project, we'll call it MyProject.jar
Make a file called Manifest.txt with the text
Class-Path: MyProject.jar
jar cfm PathingJar.jar manifest.txt MyRootPackage/*.class
Then, in your build tool, run your test directive against the pathing jar itself (don't mix-in other classes or jars). Then I was able to get my tests to run without that exception.