Class ConformanceRunner

java.lang.Object
codes.grow.packages.betterstack.testing.ConformanceRunner

public final class ConformanceRunner extends Object
Runs the shared conformance scenarios (conformance/scenarios/*.json, SPEC section 6) against targets supplied by a service's integration test.

 ConformanceReport report = ConformanceRunner.builder()
     .target("core", s -> client)
     .target("secrets", s -> provider)
     .capabilities("write", "delete", "version")
     .build()
     .run();
 report.assertPassed();
 

Only categories with a target run. Category operations are plugged in through ConformanceOps: CoreOps always, the secrets / logging / tracing operations when the package contains them, plus anything passed to ConformanceRunner.Builder.register(codes.grow.packages.betterstack.testing.ConformanceOps).

  • Field Details

    • DEFAULT_PREFIX

      public static final String DEFAULT_PREFIX
      Default value of ${prefix}.
      See Also:
    • DEFAULT_POLL_TIMEOUT

      public static final Duration DEFAULT_POLL_TIMEOUT
      How long listServices steps are repeated until their expectation passes.
    • DEFAULT_POLL_INTERVAL

      public static final Duration DEFAULT_POLL_INTERVAL
      Pause between repeated steps.
  • Method Details

    • builder

      public static ConformanceRunner.Builder builder()
      Starts a builder with CoreOps and the built-in category operations registered.
      Returns:
      a new builder
    • scenarios

      public List<Scenario> scenarios()
      Returns the scenarios of the categories that have a target, sorted by id.
      Returns:
      the scenarios
      Throws:
      UncheckedIOException - when the directory cannot be read
    • run

      public ConformanceReport run()
      Runs every selected scenario.
      Returns:
      the report
    • runScenario

      public ConformanceReport.ScenarioResult runScenario(Scenario scenario)
      Runs one scenario.
      Parameters:
      scenario - the scenario
      Returns:
      its result
    • substitute

      public static String substitute(String text, Map<String,String> vars)
      Replaces ${name} placeholders; unknown names are kept as they are.
      Parameters:
      text - text with placeholders
      vars - variables
      Returns:
      the substituted text
    • substituteNode

      public static com.fasterxml.jackson.databind.JsonNode substituteNode(com.fasterxml.jackson.databind.JsonNode node, Map<String,String> vars)
      Substitutes placeholders in every string (and object key) of a JSON tree.
      Parameters:
      node - JSON tree
      vars - variables
      Returns:
      a substituted copy