在无头模式下运行 Eclipse 时禁用错误消息对话框?

发布于 2024-12-21 09:16:03 字数 1095 浏览 1 评论 0原文

我正在尝试在构建过程中通过无头 Eclipse 执行 JUnit 测试。使用以下命令从 Ant 脚本调用单元测试:

eclipsec.exe -noSplash -application org.eclipse.ant.core.antRunner -data "C:\SomeDirectory" -buildfile "C:\Path\To \tests.xml"

这工作正常,除非 Ant 脚本因任何原因需要失败(由于单元测试失败而通过显式任务,或者因为单元测试在上游引发异常)。无论哪种情况,eclipsec 都会弹出一个对话框来报告“发生错误”。这伴随着一个例外。堆栈跟踪的顶部(如果相关的话)是:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.ant.core.AntRunner.run(AntRunner.java:513)
    at org.eclipse.ant.core.AntRunner.start(AntRunner.java:600)

我并不关心 Ant 脚本或 Eclipse 失败的原因——这就是日志记录的目的——但是随之弹出的对话框是不可接受的,因为它会挂起我们的持续集成系统,同时等待隐形用户点击它。

有什么方法可以抑制此对话框吗?有什么方法可以解决这个不需要真实用户响应的对话框?

附加信息:

Eclipse 版本:Indigo(截至昨天最新)。 Ant 和 JUnit 位于其内部。

Java版本:JDK 6.0_30 32位

操作系统:Windows(7和Server 2003)

I'm trying to execute JUnit-tests through a headless Eclipse in our build process. The unit tests are invoked from an Ant script, with this command:

eclipsec.exe -noSplash -application org.eclipse.ant.core.antRunner -data "C:\SomeDirectory" -buildfile "C:\Path\To\tests.xml"

This works fine, unless the Ant script needs to fail for any reason (either via an explicit task because a unit test failed, or because a unit test threw an exception upstream). In either case, eclipsec raises a dialog box to report that "An error has occurred." This is accompanied by an exception. The top of the stack trace, if it is relevant, is:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.ant.core.AntRunner.run(AntRunner.java:513)
    at org.eclipse.ant.core.AntRunner.start(AntRunner.java:600)

I don't really care what the Ant script or Eclipse fails for -- that's what logging is for --, but the dialog box that pops up along with it is unacceptable, because it hangs our continuous integration system while it waits for the invisible user to come click on it.

Is there any way that this dialog box can be suppressed? Is there any way I can work around this dialog box that does not require a real user to respond to it?

Additional Info:

Eclipse Version: Indigo (latest as of yesterday). Ant and JUnit internal to it.

Java Version: JDK 6.0_30 32bit

OS: Windows (7 and Server 2003)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话 2024-12-28 09:16:03

如果您使用 ErrorDialog 的子类,则有一个名为 AUTOMATED_MODE 的静态变量,您可以将其设置为 true。

事实证明(请参阅下面的评论)该错误来自包装程序 exclipsec。查看此处的命令行选项: http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html 在命令行上指定 --launcher.suppressErrors会避免这种情况对话框(注意双破折号)。

If you are using subclasses of ErrorDialog, there is a static called AUTOMATED_MODE that you can set to true.

Turns out (see the comments below) that the error is coming from the wrapper program, exclipsec. Looking at the command line options here: http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html Specifying --launcher.suppressErrors on the command line will avoid this dialog (note the double dashes).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文