Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to get Eclipse to always use common VM args for running JUnit tests?

Anyone know how to get Eclipse to use a set of default VM args? I'm getting fed up of constantly having to specify these manually every time I run a specific package, class or method within my otherwise smoothly-running test suite.

Using JUnit 4, Eclipse 3.5.

Rationale: some tests are integration tests verifying operations with large input sets so it's tedious to have to keep putting in:

-Xms256m -Xmx512m

If there's something, e.g. in Eclipse prefs, where I can specify this once and for all I'd be very grateful!

like image 213
Brian Avatar asked Nov 22 '10 14:11

Brian


People also ask

How do I set default VM arguments in Eclipse?

-- Go to the Eclipse Window > preferences, in "Java > Installed JREs". -- Copy the current default JRE with a new name, for example myJRE. -- Select the new JRE and click on the "Edit" button. -- In the "Edit JRE" dialog, add your JVM arguments in the "Default VM Arguments" field.

How do I set VM arguments for JUnit tests in Eclipse?

Run-> Run Configurations -> JUnit, select your run configuration, then you have an arguments tab to specify JVM or program arguments. You can then duplicate this run configuration to use for other tests.

How do I pass multiple VM arguments?

Step 1: Open the IDE and right-click on the application in which you want to pass VM arguments. Step 2: Click on the Run As » Run Configurations… Step 3: Click on the Arguments tab and in the VM arguments: box, type the arguments that you want to pass.


1 Answers

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.

Screenshot of JRE VM arguments

like image 169
Nick Avatar answered Sep 17 '22 14:09

Nick