简体   繁体   English

JUnit5 套件忽略类名中没有“Test”的测试

[英]JUnit5 suite ignores tests without "Test" in class name

I use junit5 and have two classes with integrations tests FooIT and TestBarIT .我使用 junit5 并有两个带有集成测试的类FooITTestBarIT 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.

相关问题 Junit测试套件,无需创建空类 - Junit Test suite without creating empty class 如何使用 Junit5 在 junit 4 中创建测试套件 - how to create test suite as in junit 4 using Junit5 测试套件从 JUnit4 迁移到 JUnit5 - Test suite migration from JUnit4 to JUnit5 Junit5 - 在带有@IncludeTags 的@Suite 中以特定且一致的运行顺序运行测试 - Junit5 - Run tests in a @Suite with @IncludeTags in a specific and consistent run order 如何在 JUnit5 中为测试套件设置自定义测试执行顺序? - How to set custom test execution order for a test suite in JUnit5? 类级别的 JUnit5 参数化测试 - JUnit5 parameterized tests at class level 有没有办法在 Junit5 的 Java 测试类中找到 @Disabled 测试? - Is there any way to find @Disabled Tests in a class of Java test class in Junit5? 通过 class 和方法名称发现 JUnit5 参数化测试抛出 org.junit.platform.commons.PreconditionViolationException - Discovering JUnit5 parameterized test via class and method name throws org.junit.platform.commons.PreconditionViolationException Junit5 永远不会在 @Suite class 内击中 @BeforeAll - Junit5 never hitting @BeforeAll inside @Suite class JUnit测试未运行-返回“空测试套件” - JUnit Tests not running - Returning “Empty test suite”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM