Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven';测试';命令,该命令仅运行失败的测试_Maven - Fatal编程技术网

Maven';测试';命令,该命令仅运行失败的测试

Maven';测试';命令,该命令仅运行失败的测试,maven,Maven,是否有方法调用maven“test”命令,该命令只运行上次调用时失败的测试?尝试使用surefire插件的参数。它看起来不像是有一个${expression}允许您从命令行更改属性,因此我将使用自己的: ... POM stuff here.... <properties> <!-- plugin's default value for this param --> <surefire.test.runOrder>filesystem<

是否有方法调用maven“test”命令,该命令只运行上次调用时失败的测试?

尝试使用surefire插件的参数。它看起来不像是有一个
${expression}
允许您从命令行更改属性,因此我将使用自己的:

... POM stuff here....
<properties>
    <!-- plugin's default value for this param -->  
    <surefire.test.runOrder>filesystem</surefire.test.runOrder>
</properties>
....
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <runOrder>${surefire.test.runOrder}</runOrder>
  </configuration>
</plugin>
....
。。。POM的东西在这里。。。。
文件系统
....
org.apache.maven.plugins
maven surefire插件
${surefire.test.runOrder}
....
然后,您可以在命令行中选择所需的设置:


mvn-Dsurefire.test.runOrder=FailedFirstTest
(或
软件包
或您想要的任何阶段)。

我不这么认为,因为这需要持久化测试输出并重新加载它。风险也很大,因为更改非测试类以通过测试应该运行所有相关的测试,而不仅仅是以前的失败。这听起来像是IDE的作业,通常由Ecilpse、Netbeans或IntelliJ支持。这对我不起作用。我第一次做了所有的测试,他们都通过了。然后我运行了您建议的命令,但结果显示它再次运行了所有测试。请尝试修改通常在最后运行的测试之一,使其失败。然后重复你的测试。失败的一个应该首先运行,然后是所有其他的。建议的配置不只是运行失败的测试,而是首先运行失败的测试。因为您的测试运行没有包括失败的测试,所以所有测试都再次运行。我明白了。但我一直在寻找一种方法,不运行上次运行时通过的测试。有办法吗?我建议在surefire插件中尝试其他配置属性。你所要求的不是一个常见的用例。当测试失败时,通常需要在代码中进行更改,我们希望确保这些更改不会修复损坏的测试,而是在其他地方破坏。正如@khmarbaise指出的,如果您只想运行单个中断的测试,那么可以在cmdline上指定测试(使用
-Dtest
)或使用IDE。