Michael Neale
Michael Neale

Reputation: 19468

Spawning a separate process from within a unit test

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.

Upvotes: 3

Views: 1613

Answers (3)

dfa
dfa

Reputation: 116324

Ant will do this for you:

<junit fork="yes">
    <jvmarg value="-Djava.compiler=NONE"/>
    ...
</junit>

Upvotes: 1

John Goering
John Goering

Reputation: 39030

Just did that exact thing using the methods explained in this question: Executing a Java application in a separate process

Upvotes: 0

Stephen C
Stephen C

Reputation: 718768

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

Upvotes: 0

Related Questions