maven - Maven + jUnit4:根据测试名称包含测试
问题描述
我试图根据测试用例名称从我的测试类中运行一些选定的测试。
下面是我的测试课的大纲
----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>
但似乎此配置用于选择测试类名称而不是测试名称。
提前致谢。
解决方案
这可以通过使用 maven 的“测试”属性来完成 要运行的测试可以定义为 testClass#testName 下面的方法有效
<project>
<properties>
<test>*#*India</test>
</properties>
</project>
并运行为
mvn test
或直接从命令行作为mvn -Dtest="*#*India"
推荐阅读
- python - 当迭代字符串python时,最后返回None
- javascript - 如何解密 kotlin 中的文本,在 nodejs 中加密?
- jwt - 如何识别来自不同租户nestjs多租户jwt的jwt令牌
- sql - cosmos DB中如何实现JOIN IN、GROUP BY等复杂SQL语句
- php - 试图获取非对象的属性“full_time”
- ios - 为什么 didSelectRowAt 函数会突出显示多行?
- c# - 在 C# 中屏蔽基于名称的长度
- google-bigquery - 如何在 Bigquery 的一个 select 语句中使用两个 group by 语句?
- docker - 我不能在 bitnami/spark docker 容器上使用 --package 选项
- c# - WPF:XAML DrawingImage 到 Path.Style