Tribunal.Evaluator (Tribunal v3.0.0)

Copy Markdown View Source

Evaluates one test case and classifies its outcome.

This module contains the evaluation semantics shared by the Mix task and Tribunal.ExUnit. It does not invoke providers, aggregate a suite, format reports, or interact with ExUnit.

Summary

Functions

Builds a failed case result when execution fails before assertions can run.

Evaluates all configured assertions for one populated test case.

Types

assertion_result()

@type assertion_result() ::
  {atom() | String.t(), {:pass | :fail, map()} | {:error, term()}}

result()

@type result() :: %{
  input: term(),
  metadata: map() | nil,
  actual_output: term(),
  status: :passed | :failed,
  failures: [{atom() | String.t(), String.t()}],
  results: map(),
  evaluations: [assertion_result()],
  execution_error: boolean(),
  duration_ms: non_neg_integer()
}

Functions

error(test_case, reason, opts \\ [])

@spec error(Tribunal.TestCase.t(), term(), keyword()) :: result()

Builds a failed case result when execution fails before assertions can run.

evaluate(test_case, assertions, opts \\ [])

@spec evaluate(Tribunal.TestCase.t(), list() | map(), keyword()) :: result()

Evaluates all configured assertions for one populated test case.

Default options are merged into each assertion, with assertion-specific options taking precedence. Missing output, missing assertions, assertion errors, and unexpected assertion results fail closed.