Setting Test Suite to Ignore
Asked Answered
K

2

9

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?

Kenti answered 12/6, 2012 at 8:0 Comment(0)
C
10

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.

Collayer answered 12/6, 2012 at 12:30 Comment(0)
S
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

Synapsis answered 24/5, 2017 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.