Java Runtime Environment Conditions - @DisabledOnJre and @EnabledOnJre

This lesson demonstrates how to disable or enable test methods or a complete test class using JRE level conditions.

We'll cover the following

@DisabledOnJre and @EnabledOnJre

Junit 5 helps us to disable or enable test cases using various conditions. JUnit Jupiter API provides annotations in org.junit.jupiter.api.condition 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 the particular version of the Java Runtime Environment (JRE) are - @DisabledOnJre and @EnabledOnJre. Let’s take a look at a demo.

Get hands-on with 1200+ tech skills courses.