有没有办法让Eclipse始终使用常见的VM args来运行JUnit测试?

Bri*_*ian 14 java eclipse junit

任何人都知道如何让Eclipse使用一组默认的VM args?每当我在运行良好的测试套件中运行特定的包,类或方法时,我总是不得不手动指定这些.

使用JUnit 4,Eclipse 3.5.

理由:一些测试是集成测试,用大输入集验证操作,因此必须继续输入是很繁琐的:

-Xms256m -Xmx512m
Run Code Online (Sandbox Code Playgroud)

如果有什么东西,例如在Eclipse prefs中,我可以一劳永逸地指定这一点,我将非常感激!

Nic*_*ick 26

If you run your tests in a separate JRE (the default, I think) then you can go to Installed JREs and specify default VM arguments for it there, as in the screenshot below (the orange buttons indicate what I clicked to access the dialog below it).

If you run your tests in the same JRE as the workspace, then the solution is to edit your eclipse.ini file and put the arguments there.

JRE VM参数的屏幕截图

  • 请记住,这将影响使用此 JVM 的所有运行目标,例如 JUnit 测试以外的目标。 (2认同)