开发者

Is it possible to exclude multiple categories in JUnit 4?

开发者 https://www.devze.com 2023-03-29 06:39 出处:网络
I would like to do something like: @RunWith(Categories.class) @Categories.IncludeCategory(Small.class) @Categories.ExcludeCate开发者_开发百科gory({Manual.class, NonFunctional.class})

I would like to do something like:

@RunWith(Categories.class)
@Categories.IncludeCategory(Small.class)
@Categories.ExcludeCate开发者_开发百科gory({Manual.class, NonFunctional.class})
@Suite.SuiteClasses(AllTests.class)
public class SmallTests {
}

but ExcludeCategories accepts only one class, not an array of classes.


This will be supported in JUnit 4.12 version, see https://github.com/junit-team/junit/blob/master/src/main/java/org/junit/experimental/categories/Categories.java


It looks like runtime-suite may provide another workaround/solution.


There's a JUnit 4 feature request for this: https://github.com/junit-team/junit/issues/146

This link also suggests a workaround:

There is a not-so-beatiful workaround. You can get multiple includes or excludes if you create an inheritance hierarchy of suites and exclude one category on each level.

0

精彩评论

暂无评论...
验证码 换一张
取 消