System Property Conditions - @DisabledIfSystemProperty and @EnabledIfSystemProperty
This lesson demonstrates how to disable or enable test methods or a complete test class using System property level conditions.
We'll cover the following
@DisabledIfSystemProperty and @EnabledIfSystemProperty
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 use system properties and specified regex to disable or enable tests are - @DisabledIfSystemProperty
and @EnabledIfSystemProperty
. Let’s take a look at a demo.
Get hands-on with 1400+ tech skills courses.