Issue
every now and then I am launching JUnit tests from within Eclipse by using
Run As > JUnit Plug-in Test
By default Eclipse assumes you are running something which requires a workbench and chooses in the "Main" section of the launch configuration
LaunchConfig > Main > Program To Run > Run an application > org.eclipse.ui.ide.workbench
I can understand why this is the default, but for me (and for all in our team) this is never ever the case. We always need to run our JUnit Plug-in Tests as
LaunchConfig > Main > Program To Run > Run an application > [No Application] Headless Mode
How do I change this default behaviour? I am currently using Eclipse 4.4.
Solution
It seems a custom LaunchConfiguration-Extension is a viable solution attempt. What I did was to create a new, custom LaunchConfiguration-Extension which is 99.999% build on the JUnitLaunchConfiguration. I only had to add a custom
BlaBlaJUnitPluginTestLauncher extends launching.JUnitLaunchConfigurationDelegate
which overrides the
launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor)
method to adjust the application parameters according to our needs.
BlaBlaJUnitPluginTestTabGroup extends org.eclipse.pde.ui.launcher.JUnitTabGroup
To be able to initialize the LaunchConfig dialog with the default parameter, I had to:
- Add a custom
BlaBlaPluginJUnitMainTab
extendsPluginJUnitMainTab
- Create a custom JUnitProgramBlock implementation (
BlaBlaJUnitProgramBlock
) - Creating an instance of
BlaBlaJUnitProgramBlock
in theBlaBlaJUnitPluginTestTabGroup.BlaBlaPluginJUnitMainTab.createProgramBlock()
method - Overriding
setDefaults
-method (not sure if its really neccessary) inBlaBlaJUnitProgramBlock
- Overriding initializeForm-method in the
BlaBlaJUnitProgramBlock
and adjust parameter there too.
Leading to the following result:
Answered By - user166566
Answer Checked By - David Goodson (JavaFixing Volunteer)