When I implement new features using TDD, I often use the shortcut Shift + Alt + D T
to run only the jUnit test case I am currently working on (and not the whole test suite, which takes a few minutes).
This creates a new Debug Configuration for the current Java source and runs it immediately. Now I would like to run the test with assertions enabled (VM option -ea
).
Unfortunately, the VM arguments for the new debug configuration starts empty. I always have to go into Debug Configurations...
→ Arguments
and add -ea
to the VM arguments input box.
Is there any way to have Eclipse these arguments populated with (project or workspace wide) default options?
-- 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.
Expand the Java section and select Installed JREs. Then in the main content window, select the JRE that you are using to run your project, and click the Edit… button. A dialog will appear, with an entry field labeled Default VM arguments.
Program Argument: Program arguments are arguments that are passed to your application, which are accessible via the "args" String array parameter of your main method. VM Argument: VM arguments are environment or system argument that needed by JVM to execute the program.
VM arguments are typically values that change the behaviour of the Java Virtual Machine (JVM). For example, the -Xmx256M argument allows the Java heap to grow to 256MB. The Eclipse runtime is also configurable via many system properties which can be passed as VM arguments in the form: -DpropertyName=propertyValue.
I think you can set this option by editing the definition of the JRE under Preferences
→ Java
→ Installed JREs
→ Select the JRE in question and edit the default VM arguments
Windows
→ Preferences
→ JUnit
has an option to add -ea
every time a new launch configuration is created. It adds the -ea
option to the Debug Configuration as well.
The full text next to a check box is:
Add
-ea
to VM arguments when creating a new JUnit launch configuration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With