8

I have many Test Suites with each one contains many Test Classes. Here is how they look like:

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses( {ATest.class, BTest.class})
public class MyFirstTestSuite {

    @BeforeClass
    public static void beforeClass() throws Exception {
                // load resources
    }

    @AfterClass
    public static void afterClass() throws Exception {
        // release resources

    }
}

Sometimes I want to disable a whole Test Suite completely. I don't want to set each test class as @Ignore, since every test suite loads and releases resources using @BeforeClass and @AfterClass and I want to skip this loading/releasing when the test suite is ignored.

So the question is: is there anything similar to @Ignore that I can use on a whole Test Suite?

boutta
  • 24,189
  • 7
  • 34
  • 49
adranale
  • 2,835
  • 1
  • 21
  • 39

2 Answers2

9

You can annotate the TestSuite with @Ignore.

@RunWith(Suite.class)
@SuiteClasses({Test1.class})
@Ignore
public class MySuite {
    public MySuite() {
        System.out.println("Hello world");
    }

    @BeforeClass
    public static void hello() {
        System.out.println("beforeClass");
    }
}

doesn't produce any output.

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
0

SlowTest is a class defined by user. It can be empty (without any functions or attributes). You can name it whatever you want:

enter image description here

enter image description here

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
Daniela
  • 11