KentBeck/junit — Issue #363: More flexible Categories implementation
Author: ahochsteger
Created: 2011-11-19 21:23:40+00:00
State: open

I would need the possibility to annotate test methods with different categories and then scan the whole classpath for matching tests:

/* MyTestSuite.java */
/** MyTestSuite runs all slow tests, excluding all test which require a network connection. */
@RunWith(FlexibleCategories.class)
@ExcludeCategory(OnlineTestCategory.class)
@IncludeCategory(SlowTestCategory.class)
@TestScanPackage("at.oeamtc.um.test")
@TestClassPrefix("")
@TestClassSuffix("Test")
public class MyTestSuite {
}

This would be an example test class:

/* SampleTest.java */
public class SampleTest {
@Test
@Category({OnlineTestCategory.class, SlowTestCategory.class})
public void onlineAndSlowTestCategoryMethod() {
}

@Test
@Category(OnlineTestCategory.class)
public void onlineTestCategoryMethod() {
}

@Test
@Category(SlowTestCategory.class)
public void slowTestCategoryMethod() {
}

@Test
public void noTestCategoryMethod() {
}
}