views:

31

answers:

1

Using junit 4.8 and the new @Category annotations, is there a way to choose a subset of categories to run with maven's surefire plugin?

For example I have:

@Test
public void a() {
}

@Category(SlowTests.class)
@Test
public void b() {
}

And I'd like to run all non-slow tests as in: (note that the -Dtest.categories was made up by me...).

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

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?

thanks

+1  A: 

It looks like this is not supported, see SUREFIRE-329 (even if this issue is/was not about JUnit 4.8, I'd recommend to vote/comment this one).

So I'm afraid you'll have to rely on "solutions" like this one for now.

Pascal Thivent