我们在 maven 中为我们的集成测试阶段生命周期定义了数百个测试,它们需要很长时间才能完成。
我想要做的只是在 integration-test
中运行一个测试.我试着做:
mvn -Dtest=<my-test> integration-test
但这不起作用。
-Dtest
只运行单元测试目标中的测试,而不是集成测试阶段。我试过 -Dintegration-test=<my-test>
相反,这被忽略了。有没有办法做到这一点 ?
我的配置是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/api/**</include>
</includes>
.....
最佳答案
如果您使用的是 Maven failsafe plugin ,您可以通过设置 it.test
来运行单个集成测试您的完全限定测试类名称的属性:
mvn -Dit.test=your.TestCase verify
见 the failsafe plugin docs for more info .
关于maven-2 - 如何在 Maven 的集成测试目标中运行单个测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/894737/