2

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?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
ernesto
  • 1,899
  • 4
  • 26
  • 39

2 Answers2

1

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.

Community
  • 1
  • 1
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
0

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

   @Ignore
   @Test
   public void test method() {}
Eddú Meléndez
  • 6,107
  • 1
  • 26
  • 35
  • If I add @Ignore, I can not optionally run them from command line. With "excludeGroups" I can change the behavior from command line with a property – ernesto Oct 14 '14 at 05:16