[英]JUnit5 suite ignores tests without "Test" in class name
I use junit5 and have two classes with integrations tests FooIT
and TestBarIT
.我使用 junit5 并有两个带有集成测试的类FooIT
和TestBarIT
。 This is my configuration这是我的配置
@RunWith(JUnitPlatform.class)
@SelectClasses({
FooIT.class, TestBarIT.class
})
@SuiteDisplayName("Suite IT")
public class SuiteIT { }
However, tests in FooIT
will be ignored if I don't add word Test
(for example TestFooIT
).但是,如果我不添加单词Test
(例如TestFooIT
),则FooIT
测试将被忽略。 But I don't want to add word Test
as we have a strict naming convention for tests.但我不想添加单词Test
因为我们有严格的测试命名约定。
Can anyone say how to make junit suite accept classes without Test
in their names or to configure it use IT
for class checking?谁能说如何让 junit 套件接受名称中没有Test
类,或者如何配置它使用IT
进行类检查?
I got the answer from JUnit team.我从 JUnit 团队那里得到了答案。
The @IncludeClassNamePatterns and @ExcludeClassNamePatterns annotations are designed explicitly for that purpose. @IncludeClassNamePatterns 和 @ExcludeClassNamePatterns 批注专门为此目的而设计。
So,所以,
@RunWith(JUnitPlatform.class)
@SelectClasses({
FooIT.class, BarIT.class
})
@SuiteDisplayName("Suite IT")
@IncludeClassNamePatterns(".*IT$")
public class SuiteIT { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.