我正在尝试根据测试用例名称从我的Test类中运行一些选定的测试。
下面是我的测试课程的概述
---- GlobalTests.java ----
@Test
public void myTest_India(){ --- }
@Test
public void myTest_Germany() { --- }
---- GlobalIntegrationTests.java ----
@Test
public void myIntegrationTest_India(){ --- }
@Test
public void myIntegrationTest_Germany() { --- }
我如何指示我的Maven仅运行“印度”测试?
我已经尝试了如下的maven surefire插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>%regex[*Test_India*]</include>
</includes>
</configuration>
</plugin>
但似乎此配置用于选择测试类名称而不是测试名称。
谢谢。
答案 0 :(得分:0)
这可以通过使用maven的'test'属性来完成 可以将要运行的测试定义为testClass#testName 以下方法有效
<project>
<properties>
<test>*#*India</test>
</properties>
</project>
并以
运行mvn test
或直接在命令行中以mvn -Dtest="*#*India"