如何在junit4中包含多个类别? [英] How to include multiple categories in junit4?
问题描述
我想为junit跑步者添加多个类别.
I want to include multiple categories for a junit runner.
Java代码
@RunWith(Categories.class)
@IncludeCategory(IMAP.class , POP.class)
@SuiteClasses({MailTestSuites.class})
public class TestSuiteRunner{
}
我只想针对这两个类别运行测试套件.我有邮件套件的类别,例如"IMAP,POP,SMTP,POP3".现在,我只想运行"IMAP,POP"类别套件. 我如何与junit一起运行?
I want to run my test suite for these two categories only. I have categories for mail suite like "IMAP,POP , SMTP , POP3". Now , I want to run only "IMAP , POP" category suites only. How can I run with junit?
推荐答案
直到JUnit 4.11版本,@IncludeCategory
和@ExcludeCategory
仅支持一个值.但是,从即将发布的4.12版本开始,将允许它传递多个值.
Up to version JUnit 4.11, @IncludeCategory
and @ExcludeCategory
only support one value. However, starting with the upcoming release 4.12, it will be allowed to pass multiple values.
根据源代码中的文档,然后您可以编写:
According to the documentation in the source code, you can then write:
@RunWith(Categories.class)
@IncludeCategory({IMAP.class, POP.class})
@SuiteClasses({MailTestSuites.class})
这篇关于如何在junit4中包含多个类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!