Disabling Tests
Entire test classes or individual test methods may be disabled via the @Disabled
annotation, via one of the annotations discussed in
Conditional Test Execution, or via a custom ExecutionCondition.
When @Disabled is applied at the class level, all test methods within that class are
automatically disabled as well.
If a test method is disabled via @Disabled, that prevents execution of the test method
and method-level lifecycle callbacks such as @BeforeEach methods, @AfterEach methods,
and corresponding extension APIs. However, that does not prevent the test class from being
instantiated, and it does not prevent the execution of class-level lifecycle callbacks
such as @BeforeAll methods, @AfterAll methods, and corresponding extension APIs.
Here’s a @Disabled test class.
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@Disabled("Disabled until bug #99 has been fixed")
class DisabledClassDemo {
@Test
void testWillBeSkipped() {
}
}
And here’s a test class that contains a @Disabled test method.
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
class DisabledTestsDemo {
@Disabled("Disabled until bug #42 has been resolved")
@Test
void testWillBeSkipped() {
}
@Test
void testWillBeExecuted() {
}
}
|
|
|
|