Package rife.bld.extension.testing
Class DisabledOnCiCondition
java.lang.Object
rife.bld.extension.testing.DisabledOnCiCondition
- All Implemented Interfaces:
ExecutionCondition,Extension
Implementation of JUnit's
ExecutionCondition to conditionally disable tests when running in a CI/CD
environment.
This condition determines whether a test or test container should be enabled or disabled based on the presence of
the CI environment variable. If the variable is set, the condition disables the test; otherwise, it enables
the test.
The presence of the CI environment variable is typically an indicator that the code is running in a CI/CD
pipeline, as this variable is automatically defined in most CI environments such as GitHub Actions, GitLab CI, and
others.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEvaluates whether the execution of a test should be enabled or disabled based on the CI environment.static booleanisCi()Returnstrueif the environment variableCIis set.
-
Constructor Details
-
DisabledOnCiCondition
public DisabledOnCiCondition()
-
-
Method Details
-
isCi
public static boolean isCi()Returnstrueif the environment variableCIis set.- Returns:
trueif the environment variableCIis set,falseotherwise
-
evaluateExecutionCondition
Evaluates whether the execution of a test should be enabled or disabled based on the CI environment.Returns a disabled state if the test is running in a CI/CD environment, otherwise returns an enabled state.
- Specified by:
evaluateExecutionConditionin interfaceExecutionCondition- Parameters:
context- theExtensionContextfor the current test or container- Returns:
- a
ConditionEvaluationResultindicating whether the test is enabled or disabled
-