Class Categories

  • All Implemented Interfaces:
    Describable, Filterable, Sortable

    public class Categories
    extends Suite
    From a given set of test classes, runs only the classes and methods that are annotated with either the category given with the @IncludeCategory annotation, or a subtype of that category. 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 static class A {
      @Test
      public void a() {
          fail();
         }
    
      @Category(SlowTests.class)
      @Test
      public void b() {
         }
     }
    
     @Category( { SlowTests.class, FastTests.class })
     public static class B {
      @Test
      public void c() {
    
         }
     }
    
     @RunWith(Categories.class)
     @IncludeCategory(SlowTests.class)
     @SuiteClasses( { A.class, B.class })
     // Note that Categories is a kind of Suite
     public static class SlowTestSuite {
     }