排除在IntellIJ中运行的测试 [英] Excluding tests from being run in IntellIJ

查看:378
本文介绍了排除在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 运行配置中将测试种类设置为模式,将以下正则表达式指定为模式:

In the JUnit Run configuration set the Test kind to Pattern, specify the following regular expression as the pattern:

^(?!.*IT$).*$

它与班级名称匹配,因此您无需匹配 .java 扩展名。如果类名以<$ h $ c> 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆