Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude multiple categories in JUnit 4?

Tags:

java

junit4

I would like to do something like:

@RunWith(Categories.class)
@Categories.IncludeCategory(Small.class)
@Categories.ExcludeCategory({Manual.class, NonFunctional.class})
@Suite.SuiteClasses(AllTests.class)
public class SmallTests {
}

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

like image 640
Noel Yap Avatar asked Aug 17 '11 16:08

Noel Yap


People also ask

What is@ category annotation?

@IncludeCategory annotation indicates which categories will be included in execution. For the below example, we included SlowTest category and it will be executed. Thus, test method b() of class A, method c() of class B will be executed.

How do JUnit tests work?

JUnit provides static methods to test for certain conditions via the Assert class. These assert statements typically start with assert. They allow you to specify the error message, the expected and the actual result. An assertion method compares the actual value returned by a test to the expected value.


1 Answers

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

like image 140
Heezer Avatar answered Sep 28 '22 13:09

Heezer