O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conditional extension points

In order to create extensions that activate or deactivate tests depending on a given condition, JUnit 5 provides one conditional extension point callled ExecutionCondition. The following snippet shows the declaration of this extension point:

package org.junit.jupiter.api.extension;import static org.apiguardian.api.API.Status.STABLE;import org.apiguardian.api.API;@FunctionalInterface@API(status = STABLE, since = "5.0")public interface ExecutionCondition extends Extension {   ConditionEvaluationResult evaluateExecutionCondition              ExtensionContext context);}

The extension can be used to deactivate either all tests in a container (likely a class) or individual tests (likely a test method). Examples of this extension ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required