Class DisabledOnCiCondition

java.lang.Object
rife.bld.extension.testing.DisabledOnCiCondition
All Implemented Interfaces:
ExecutionCondition, Extension

public class DisabledOnCiCondition extends Object implements ExecutionCondition
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 Details

    • DisabledOnCiCondition

      public DisabledOnCiCondition()
  • Method Details

    • isCi

      public static boolean isCi()
      Returns true if the environment variable CI is set.
      Returns:
      true if the environment variable CI is set, false otherwise
    • evaluateExecutionCondition

      public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context)
      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 interface ExecutionCondition
      Parameters:
      context - the ExtensionContext for the current test or container
      Returns:
      a ConditionEvaluationResult indicating whether the test is enabled or disabled