Operating System Conditions - @DisabledOnOs and @EnabledOnOs

This lesson demonstrates how to disable or enable the test method or a complete test class using OS-level conditions.

We'll cover the following

@DisabledOnOs and @EnabledOnOs

Junit 5 helps us to disable or enable test cases using various conditions. JUnit Jupiter API provides annotations in org.junit.jupiter.api.condition - https://junit.org/junit5/docs/5.3.2/api/org/junit/jupiter/api/condition/package-summary.html

package to enable/disable tests based on a certain condition. The annotations provided by API can be applied to test methods as well as the class itself. The two annotations which are applied to disable/enable tests based on Operating system are - @DisabledOnOs and @EnabledOnOs. Let’s take a look at a demo.

Get hands-on with 1200+ tech skills courses.