Imagine the situation that your project must be built on several environments.
Imagine that all tests you've implemented must not be run on each environment.
And you prefer to select which of them should be run by setting it up with... `application.properties` file with concrete property per test.
Looks like delicious, doesn't it?
# Settings
First of all let's disable JUnit 4 supplied in SpringBoot2 by default and enable [JUnit 5](https://junit.org/junit5/docs/current/user-guide/#overview).
return ConditionEvaluationResult.enabled("Enabled by property: "+property);
} else {
return ConditionEvaluationResult.disabled("Disable by property: "+property);
}
}
return ConditionEvaluationResult.enabled("Enabled by default");
}
}
```
You must create a class (without Spring @Component annotation) which implements ExecutionCondition interface.
Then you must implement one method of this interface - `ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context)`.
This method takes JUnit test's execution context and returns the condition - should the test be started or not. Simply, right?
You can read more about [Conditional test execution with JUnit5](https://junit.org/junit5/docs/current/user-guide/#extensions-conditions) in official documentation as well.
But how to check application property in this context?
## Obtaining the access to SpringBoot context from JUnit context
Here is the snippet to obtain Spring environment right from the ExtensionContext of JUnit: