views:

269

answers:

1

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.

+1  A: 

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

Chris Dennett
It will only fork one new JVM for the entire test suite, not one for each single test.
Michael Borgwardt
Might still be useful.
Chris Dennett
@Michael - if the forkmode attribute is set to "perTest" then a new JVM should be created for each test - this is the default.
Reuben Peeris
The link appears broken -- try this one: http://ant.apache.org/manual/Tasks/junit.html
Steve Powell
Ohh, it worked when I first answered this -- I'll edit my answer :)
Chris Dennett