Ray Kiddy
Ray Kiddy

Reputation: 3609

How can I get eclipse to create Run Configurations for junit with extra parameters?

When I run unit tests in the eclipse IDE, I need to use the "-noverify" JVM parameter.

I can do this once for my class with 30 test methods, and it is fine. The very first time I run, it fails. I go in to the Run Configuration pane and add the "-noverify" option for the JVM. It works.

But then if I select any of the individual test methods and select "Run As... Junit", that creates a new Run Configuration, and it again fails and I have to again add it to the Configuration as a JVM parameter. Every. Single. Time. If I want to run the methods one at a time, I need to watch it fail and set the option 30 times.

Is there any way to tell eclipse, for a project or a system or whatever, that when it creates a new Run Configuration for a unit test, I need this option to be applied?

Upvotes: 1

Views: 1779

Answers (1)

glytching
glytching

Reputation: 47865

You can set default JVM arguments which will be applied to every launch configuration:

  • Window > Preferences > Java > Installed JRE
  • Select your JRE and click Edit
  • Add -noverify to the Default VM Arguments

Now every JUnit test and, more broadly, every JRE instance spawned by Eclipse will run with this option. If that scope is too broad then you may want to consider the Eclipse Runner plugin as a way of managing launch configurations specific to your tests.

Upvotes: 1

Related Questions