如何在Maven的集成测试目标中运行单个测试 [英] How to run individual test in the integration-test target in maven
问题描述
我们为maven中的集成测试阶段生命周期定义了数百种测试,它们需要很长时间才能完成.
We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish.
我想做的只是在integration-test
中运行一个测试.我试着做:
What I want to do is run just one test in the integration-test
. I tried doing :
mvn -Dtest=<my-test> integration-test
但这不起作用. -Dtest
仅运行单元测试目标中的测试,而不运行集成测试阶段.我改用-Dintegration-test=<my-test>
,但被忽略了.
but that does not work. The -Dtest
runs only the tests in the unit test goal, not the integration-test phase. I tried the -Dintegration-test=<my-test>
instead, and that was ignored.
有没有办法做到这一点?
Is there a way to do that ?
我的配置是:
<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>
.....
推荐答案
If you're using the Maven failsafe plugin, you can run a single integration test by setting the it.test
property to your fully qualified test class name:
mvn -Dit.test=your.TestCase verify
有关详细信息,请参见故障安全插件文档 a>.
See the failsafe plugin docs for more info.
这篇关于如何在Maven的集成测试目标中运行单个测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!