问题描述
默认情况下,Eclipse假定您正在运行需要工作台的东西,并在启动配置的主部分中选择
我可以理解为什么这是默认的,但对于我(和我们团队中的所有人)来说,从来没有这样。我们总是需要运行我们的JUnit插件测试作为
如何更改此默认行为?
我正在使用Eclipse 4.4。
似乎是一个自定义的 LaunchConfiguration 是一个可行的解决方案。
我做的是创建一个新的,定制的 LaunchConfiguration -Extension,它是99.999%构建在JUnitLaunchConfiguration 上。我只需要添加一个自定义
BlaBlaJUnitPluginTestLauncher extends launching.JUnitLaunchConfigurationDelegate
它覆盖
launch(ILaunchConfiguration,String,ILaunch, IProgressMonitor)
方法根据需要调整应用程序参数。
BlaBlaJUnitPluginTestTabGroup扩展org.eclipse.pde.ui.launcher.JUnitTabGroup
为了能够初始化具有默认参数的LaunchConfig对话框,我必须:
- 添加自定义
BlaBlaPluginJUnitMainTab
扩展PluginJUnitMainTab
- 创建自定义JUnitProgramBlock实现(
BlaBlaJUnitProgramBlock
) - 在
BlaBlaJUnitPluginTestTabGroup中创建一个
方法BlaBlaJUnitProgramBlock
的实例。 BlaBlaPluginJUnitMainTab.createProgramBlock() - 在
中覆盖
setDefaults
-method(不确定是否真的必要)BlaBlaJUnitProgramBlock - 在
BlaBlaJUnitProgramBlock
中覆盖initializeForm方法,并调整参数。
导致以下结果:
every now and then I am launching JUnit tests from within Eclipse by using
By default Eclipse assumes you are running something which requires a workbench and chooses in the "Main" section of the launch configuration
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
How do I change this default behaviour?I am currently using Eclipse 4.4.
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:
这篇关于更改默认值“运行程序”在Eclipse中启动配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!