Java Eclipse 调试配置中的默认 VM 参数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1131594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 00:06:46  来源:igfitidea点击:

Default VM arguments in Eclipse debug configuration?

javaeclipse

提问by Bluehorn

When I implement new features using TDD, I often use the shortcut Shift + Alt + D Tto run only the jUnit test case I am currently working on (and not the whole test suite, which takes a few minutes).

当我使用 TDD 实现新功能时,我经常使用快捷方式Shift + Alt + D T只运行我当前正在处理的 jUnit 测试用例(而不是整个测试套件,这需要几分钟)。

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).

这将为当前 Java 源创建一个新的调试配置并立即运行它。现在我想在启用断言的情况下运行测试(VM 选项-ea)。

Unfortunately, the VM arguments for the new debug configuration starts empty. I always have to go into Debug Configurations...Argumentsand add -eato the VM arguments input box.

不幸的是,新调试配置的 VM 参数开始时为空。我总是必须进入Debug Configurations...Arguments并添加-ea到 VM 参数输入框。

Is there any way to have Eclipse these arguments populated with (project or workspace wide) default options?

有没有办法让 Eclipse 这些参数填充(项目或工作区范围内的)默认选项?

采纳答案by RAbraham

WindowsPreferencesJUnithas an option to add -eaevery time a new launch configuration is created. It adds the -eaoption to the Debug Configuration as well.

WindowsPreferences→每次创建新的启动配置时JUnit都有一个添加选项-ea。它还-ea向调试配置添加了该选项。

The full text next to a check box is:

复选框旁边的全文是:

Add -eato VM arguments when creating a new JUnit launch configuration

-ea创建新的 JUnit 启动配置时添加到 VM 参数

回答by Rich Seller

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.

我能看到的唯一方法是贡献一个新的启动配置,这不是一项微不足道的任务,但如果您有 PDE 经验,这不是太难。

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

有一篇eclipse.org 文章(请参阅“创建启动配置”)描述了如何构建配置并启动它们。

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.

我想您可以复制 JUnit 实现(请参阅 org.eclipse.jdt.junit 中的 org.eclipse.debug.core.launchConfigurationTypes 扩展)并将您选择的默认值添加到该配置中。然后你需要声明一个键绑定来启动它并将插件打包到你的安装中。

回答by Grem

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

我认为您可以通过在PreferencesJavaInstalled JREs→下编辑 JRE 的定义来设置此选项,然后选择有问题的 JRE 并编辑默认的 VM 参数