Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running each JUnit test in a separate JVM in Eclipse?

I have a project with nearly 500 individual tests in around 200 test classes. Some of these tests don't do a great job of tearing down their own state after they're finished, and in Eclipse this results in some tests failing. The tests all pass when running the test suite from the command line via Ant.

Can I enable 'test isolation' somehow in Eclipse? I don't mind if it takes longer to run.

Long term, I will clean up the misbehaving tests, but in the short term I'd like to get the tests working.

like image 862
HenryR Avatar asked May 23 '10 00:05

HenryR


People also ask

How do I set VM arguments for JUnit tests in Eclipse?

Run-> Run Configurations -> JUnit, select your run configuration, then you have an arguments tab to specify JVM or program arguments. You can then duplicate this run configuration to use for other tests.

Can JUnit run in parallel?

Once parallel test execution property is enabled, the JUnit Jupiter engine will execute tests in parallel according to the provided configuration with declared synchronization mechanisms.


1 Answers

If you use Ant in Eclipse, you can set the JUnit task to fork a new JVM process for each test, providing isolation.

http://ant.apache.org/manual/Tasks/junit.html

like image 127
Chris Dennett Avatar answered Sep 20 '22 20:09

Chris Dennett