Maven'test'命令只运行失败的测试

Gli*_*ide 5 maven

有没有办法调用maven'test'命令,它只运行上次调用时失败的测试?

use*_*849 5

尝试使用surefire插件的runOrder参数.看起来它${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>
....
Run Code Online (Sandbox Code Playgroud)

然后,您可以在命令行中选择所需的设置:

mvn -Dsurefire.test.runOrder=failedfirst test(或者package你想要的任何阶段).

  • 我知道了。但我一直在寻找一种*不*运行上次运行期间通过的测试的方法。有办法吗? (3认同)