In order to establish custom conditions for test execution, we need to use the JUnit 5 extension model (introduced in Chapter 2, What's new in JUnit 5, in the section The extension model of JUnit 5). Concretely, we need to use the conditional extension point called ExecutionCondition. This extension can be used to deactivate either all tests in a class or individual tests.
We are going to see a working example in which we create a custom annotation to disable tests based on the operative system. First of all, we create a custom utility enumeration to select one operative system (WINDOWS, MAC, LINUX, and OTHER):
package io.github.bonigarcia;
public enum Os {
WINDOWS, MAC, LINUX, OTHER;
public static Os determine() {
Os out = OTHER;
String myOs = System.getProperty("os.name").toLowerCase();
if (myOs.contains...