public class Categories extends Suite
Note that, for now, annotating suites with @Category has no effect.
Categories must be annotated on the direct method or class.
Example:
public interface FastTests {
}
public interface SlowTests {
}
public interface SmokeTests
}
public static class A {
@Test
public void a() {
fail();
}
@Category(SlowTests.class)
@Test
public void b() {
}
@Category({FastTests.class, SmokeTests.class})
@Test
public void c() {
}
}
@Category({SlowTests.class, FastTests.class})
public static class B {
@Test
public void d() {
}
}
@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@SuiteClasses({A.class, B.class})
// Note that Categories is a kind of Suite
public static class SlowTestSuite {
// Will run A.b and B.d, but not A.a and A.c
}
Example to run multiple categories:
@RunWith(Categories.class)
@IncludeCategory({FastTests.class, SmokeTests.class})
@SuiteClasses({A.class, B.class})
public static class FastOrSmokeTestSuite {
// Will run A.c and B.d, but not A.b because it is not any of FastTests or SmokeTests
}
| Modifier and Type | Class and Description |
|---|---|
static class |
Categories.CategoryFilter |
static interface |
Categories.ExcludeCategory |
static interface |
Categories.IncludeCategory |
Suite.SuiteClasses| Constructor and Description |
|---|
Categories(java.lang.Class<?> klass,
RunnerBuilder builder) |
describeChild, emptySuite, getChildren, runChildchildrenInvoker, classBlock, classRules, collectInitializationErrors, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, isIgnored, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClassespublic Categories(java.lang.Class<?> klass,
RunnerBuilder builder)
throws InitializationError
InitializationError