ernesto
ernesto

Reputation: 1989

Junit excluded tests are not shown up as Skipped

We have a typical Maven/Surefire/Junit setup. We have categorized some of the tests as SlowTests with Junit categories feature.

When we run the test(mvn test) the default behavior is to skip the SlowTests. We have done this by defining "excludedGroups" in surefire definition.

I thought that in the test output, the excluded tests will count towards number of "Skipped" tests. But the "Skipped" tests are always shown as '0'!!

How to make these excluded tests to count towards "Skipped" tests? In general, when will Junit/Surefire show "Skipped" tests > 0?

Upvotes: 2

Views: 672

Answers (2)

Duncan Jones
Duncan Jones

Reputation: 69329

Skipped means that the test was a candidate for Surefire to execute, but an @Ignore was found or an Assume statement failed.

If you want your slow tests to appear as skipped, you could use Maven to set a system property and test for that with an Assume statement in a @BeforeClass method. Perhaps your slow tests could extend a parent class which performs this check.

The Surefire plugin can also set environment variables if you want to do it that way, see https://stackoverflow.com/a/9622482/474189.

Upvotes: 1

Eddú Meléndez
Eddú Meléndez

Reputation: 6530

Add @Ignore above the test method. Something like that:

   @Ignore
   @Test
   public void test method() {}

Upvotes: 0

Related Questions