views:

81

answers:

3

I have some unit tests (yes, perhaps more integration-ey tests !) that I would like to spin up another jvm, and then run the test code from that "other" JVM (and wait for it to finish, collecting the results). Am interested if there is an easy/reliable way of doing that with junit (eg inherit the classpath of what is needed etc...)

Any ideas appreciated.

+1  A: 

ant will do this for you:

<junit fork="yes">
    <jvmarg value="-Djava.compiler=NONE"/>
    ...
</junit>
dfa
well that works for ant - any way to do it programmatically?
Michael Neale
You could look at how Ant does it. Basically it just does `Runtime.getRuntime().exec("javac")`.
Tim Sylvester
A: 

Have a read through the JUnit Tools pages. There entries for tools etc that support system testing, integration testing, etc in various forms.

Stephen C
A: 

Just did that exact thing using the methods explained in this question: http://stackoverflow.com/questions/636367/java-executing-a-java-application-in-a-separate-process

Epaga