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 boolean
isCi()
Returnstrue
if the environment variableCI
is set.
-
Constructor Details
-
DisabledOnCiCondition
public DisabledOnCiCondition()
-
-
Method Details
-
isCi
public static boolean isCi()Returnstrue
if the environment variableCI
is set.- Returns:
true
if the environment variableCI
is set,false
otherwise
-
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:
evaluateExecutionCondition
in interfaceExecutionCondition
- Parameters:
context
- theExtensionContext
for the current test or container- Returns:
- a
ConditionEvaluationResult
indicating whether the test is enabled or disabled
-