请帮我解决这个问题。我不太明白日志中的错误是什么意思。

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.749s
[INFO] Finished at: Thu Apr 24 10:10:20 IST 2014
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project samples.simpleforwarding: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0_55\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefirebooter53410321571238933.jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire86076271125218001tmp E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire_01846991116135903536tmp"
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

当前回答

在调试模式下运行了几十次Maven之后,我遇到了这样的情况:

-Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"

由于某些原因,我不得不杀死仍在并行运行的额外java进程。

其他回答

Surefire FAQ的这一部分可以帮助你:

Surefire fails with the message "The forked VM terminated without properly saying goodbye" Surefire does not support tests or any referenced libraries calling System.exit() at any time. If they do so, they are incompatible with surefire and you should probably file an issue with the library/vendor. Alternatively the forked VM could also crash for a number of reasons, which can also make this issue happen. Look for the classical "hs_err*" files indicating VM crashes or examine the log output from running maven when the tests execute. Some "extraordinary" output from crashing processes may be dumped to the console/log. If this happens on a CI environment and only after some time runs there is a fair chance your test suite is leaking some kind of OS-level resource that makes things worse for every run. Regular os-level monitoring tools may give you some indication.

您可以使用以下命令。因为你的单元测试需要分叉。关于你在单元测试中使用线程的问题。

mvn test -DforkCount=2

我希望。它有帮助。

对于我的例子,它是我的代码调用System.exit(0)。

以下是关于它的文档摘录:

Surefire在任何时候都不支持调用System.exit()的测试或任何引用库。如果他们这样做,他们与Surefire不兼容,你可能应该向库/供应商提交一个问题。

我遇到了和查德类似的情况,但找到了不同的答案。

根据插件文档,你不能使用${…}在<argLine>中,因为Maven将在surefire插件(或任何其他插件)之前拾取它进行替换。

从2.17版本开始,插件支持@{…}而不是${…}用于属性替换。

举个例子,替换这个

<argLine>XX:MaxPermSize=1024m ${moreArgs}</argLine>

用这个

<argLine>XX:MaxPermSize=1024m @{moreArgs}</argLine>

最近travis终止了一个测试的执行(没有改变任何相关的东西(以及在开发人员机器上成功的构建!)),因此BUILD FAILURE。 原因之一是这样的(见@agudian的答案):

Surefire不支持调用System.exit()的测试或任何引用库

(因为测试类确实称为System.exit(-1))。

相反,使用简单的return语句会有所帮助。 为了让travis再次开心,我还必须添加@xiaohuo提供的surefire参数(<argLine>)。(此外,我必须删除-XX:MaxPermSize=256m,以便能够在我的一个台式机上构建)

只做这两件事中的一件是行不通的。

要了解更多背景知识,请阅读何时调用系统。退出Java。