排除在 IntellIJ 中运行的测试 [英] Excluding tests from being run in IntellIJ
问题描述
IntelliJ IDEA Ultimate 中是否没有排除某些测试的选项?我想在 IntelliJ 中运行单元测试但排除集成测试.我将集成测试命名为 *IT.java
,这样 Maven 故障安全插件就可以将它们与单元测试分开运行.
Is it no option to exclude some tests in IntelliJ IDEA Ultimate? I want to run unit tests in IntelliJ but exclude the integration tests. I name the integration tests with *IT.java
so the Maven failsafe plugin can run them seperatly from the unit tests.
推荐答案
在JUnit
运行配置中,将Test kind
设置为Pattern,指定以下正则表达式作为模式:
In the JUnit
Run configuration set the Test kind
to Pattern, specify the following regular expression as the pattern:
^(?!.*IT$).*$
它与类名匹配,因此您不需要匹配 .java
扩展名.如果使用 否定前瞻,类名以 IT
结尾,则正则表达式将不匹配.
It matches against the class name, so you don't need to match .java
extension. Regular expression will not match if the class name ends with IT
using the negative lookahead.
这篇关于排除在 IntellIJ 中运行的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!