17

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?

Stewart
  • 17,616
  • 8
  • 52
  • 80
Bluehorn
  • 2,956
  • 2
  • 22
  • 29

3 Answers3

40

I think you can set this option by editing the definition of the JRE under PreferencesJavaInstalled JREs → Select the JRE in question and edit the default VM arguments

Stewart
  • 17,616
  • 8
  • 52
  • 80
Grem
  • 581
  • 1
  • 3
  • 5
  • 2
    Thanks! This solves my problem, while it is not exactly the feature I was looking for. With this solution the "VM arguments" in the debug configuration stay empty, and the "default VM arguments" are added silently when launching. I think, Eclipse should at least show the "default VM arguments" that are added in the debug configuration dialog. The downside is that you can't remove from the default VM arguments for a specific configuration (which is not the sense of default that I like :)) – Bluehorn Jul 16 '09 at 08:02
11

WindowsPreferencesJUnit 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

Stewart
  • 17,616
  • 8
  • 52
  • 80
RAbraham
  • 5,956
  • 8
  • 45
  • 80
2

Only way I can see to do it is to contribute a new launch configuration, this is not a trivial task but not too hard if you have PDE experience.

There is an eclipse.org article (see "Creating a Launch Configuration") that describes how to construct configurations and launch them.

I guess you could copy the JUnit implementation (see the org.eclipse.debug.core.launchConfigurationTypes extension in org.eclipse.jdt.junit) and add in your chosen defaults to that config. You'd then need to declare a key binding to launch it and package the plugin to your install.

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
  • Thanks for the pointer, I'll consider creating a special launch configuration when I have some spare time (rarely ;-)). I'll go with the answer by Grem for now (somehow I missed the default VM arguments field in the JVM config). – Bluehorn Jul 16 '09 at 08:05