在 Eclipse 的单独 JVM 中运行每个 JUnit 测试? [英] Running each JUnit test in a separate JVM in Eclipse?

查看:32
本文介绍了在 Eclipse 的单独 JVM 中运行每个 JUnit 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中包含大约 200 个测试类中的近 500 个单独测试.其中一些测试在完成后并没有很好地销毁它们自己的状态,而在 Eclipse 中这会导致一些测试失败.通过 Ant 从命令行运行测试套件时,测试全部通过.

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.

我可以在 Eclipse 中以某种方式启用测试隔离"吗?我不介意运行时间是否更长.

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.

推荐答案

如果你在Eclipse中使用Ant,你可以设置JUnit任务为每个测试fork一个新的JVM进程,提供隔离.

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

这篇关于在 Eclipse 的单独 JVM 中运行每个 JUnit 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆