title: How to run JUnit tests by category in Maven?
body: <p>Using JUnit 4.8 and the new <code>@Category</code> annotations, is there a way to choose a subset of categories to run with Maven's Surefire plugin?</p>
  
  <p>For example I have:</p>
  
  <pre><code>@Test
  public void a() {
  }
  
  @Category(SlowTests.class)
  @Test
  public void b() {
  }
  </code></pre>
  
  <p>And I'd like to run all non-slow tests as in: (note that the -Dtest.categories was made up by me...).</p>
  
  <pre><code>mvn test -Dtest.categories=!SlowTests // run non-slow tests
  mvn test -Dtest.categories=SlowTests // run only slow tests
  mvn test -Dtest.categories=SlowTests,FastTests // run only slow tests and fast tests
  mvn test // run all tests, including non-categorized
  </code></pre>
  
  <p>So the point is that I don't want to have to create test suites (Maven just picks up all unit tests in the project which is very convenient) and I'd like Maven to be able to pick the tests by category.
  I think I just made up the -Dtest.categories, so I was wondering if there's a similar facility I can use?</p>