简体   繁体   English

在Eclipse中的单独JVM中运行每个JUnit测试?

[英]Running each JUnit test in a separate JVM in Eclipse?

I have a project with nearly 500 individual tests in around 200 test classes. 我有一个项目,在大约200个测试类中有近500个单独的测试。 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. 其中一些测试在完成后没有很好地拆除自己的状态,而在Eclipse中,这导致一些测试失败。 The tests all pass when running the test suite from the command line via Ant. 当从命令行通过Ant运行测试套件时,测试全部通过。

Can I enable 'test isolation' somehow in Eclipse? 我可以在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. 长期来看,我会清理行为不端的测试,但在短期内我想让测试工作。

If you use Ant in Eclipse, you can set the JUnit task to fork a new JVM process for each test, providing isolation. 如果在Eclipse中使用Ant,则可以将JUnit任务设置为为每个测试分叉新的JVM进程,从而提供隔离。

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

I also had similar needs and developed small maven plugin Jute which has been published in maven central. 我也有类似的需求,并开发了小型maven插件Jute ,已在maven central发布。 It starts external JVM process for each JUnit test method. 它为每个JUnit测试方法启动外部JVM进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM