我想运行名称以“UnitTest”结尾的所有测试类。我正在使用 Intellij 2017.2.5 并尝试创建 JUnit 运行/调试配置并仅选择具有特定格式 (*UnitTest) 的类。
不幸的是,即使使用模式测试类型也不起作用。
所以我的问题是:如何在 Intellij 上创建 JUnit Run 配置以仅运行以“UnitTest”完成的测试类?
最佳答案
看看 Maven Surefire 插件,它可以根据确切的名称或模式包含/排除测试源。 Here您可以找到更多详细信息。
从技术上讲,与此类似的配置应该可以完成工作:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<includes>
<include>%regex[.*UnitTest.*]</include>
</includes>
</configuration>
</plugin>
</plugins>
关于java - 使用 JUnit 在 Intellij 上运行特定测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51750304/