Running each JUnit test in a separate JVM in Eclipse?

佐手、 提交于 2019-11-27 17:42:29

问题


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:


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




回答2:


I also had similar needs and developed small maven plugin Jute which has been published in maven central. It starts external JVM process for each JUnit test method.



来源:https://stackoverflow.com/questions/2890259/running-each-junit-test-in-a-separate-jvm-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!