dream_test/reporters/types

Reporter event types emitted during a run.

These types are produced by Dream Test’s runner/executors and consumed by reporters (see dream_test/reporters). You usually don’t construct events yourself; you pattern match on them if you’re implementing a custom reporter.

Terminology

Event model

A typical run looks like:

Hook events (HookStarted / HookFinished) can be interleaved when you use lifecycle hooks.

Types

Which parts of a BDD report to print at the end of the run.

pub type BddOutputMode {
  BddFull
  BddFailuresOnly
  BddSummaryOnly
}

Constructors

  • BddFull

    Print the full hierarchical results, then repeat failures, then summary.

  • BddFailuresOnly

    Print failures (repeated) and summary only.

  • BddSummaryOnly

    Print summary only.

Configuration for the BDD results reporter.

pub type BddReporterConfig {
  BddReporterConfig(color: Bool, mode: BddOutputMode)
}

Constructors

Which lifecycle hook is running.

Example

let event =
  reporter_types.HookFinished(
    kind: reporter_types.AfterEach,
    scope: ["file"],
    test_name: Some("delete"),
    outcome: reporter_types.HookError(message: "boom"),
  )
pub type HookKind {
  BeforeAll
  BeforeEach
  AfterEach
  AfterAll
}

Constructors

  • BeforeAll
  • BeforeEach
  • AfterEach
  • AfterAll

Whether a hook succeeded or failed.

Example

use message <- result.try(hook_error_message(event))

message
|> should
|> be_equal("boom")
|> or_fail_with("expected hook error message 'boom'")
pub type HookOutcome {
  HookOk
  HookError(message: String)
}

Constructors

  • HookOk
  • HookError(message: String)

Configuration for the JSON results reporter.

pub type JsonReporterConfig {
  JsonReporterConfig(pretty: Bool)
}

Constructors

  • JsonReporterConfig(pretty: Bool)

Events emitted during a test run, suitable for progress indicators.

scope is the describe/group path (e.g. ["file", "delete"]). For per-test hooks, test_name is the leaf it name.

Example

use total <- result.try(
  run_started_total(reporter_types.RunStarted(total: 3)),
)

total
|> should
|> be_equal(3)
|> or_fail_with("expected total to be 3")
pub type ReporterEvent {
  RunStarted(total: Int)
  TestFinished(
    completed: Int,
    total: Int,
    result: types.TestResult,
  )
  HookStarted(
    kind: HookKind,
    scope: List(String),
    test_name: option.Option(String),
  )
  HookFinished(
    kind: HookKind,
    scope: List(String),
    test_name: option.Option(String),
    outcome: HookOutcome,
  )
  RunFinished(
    completed: Int,
    total: Int,
    results: List(types.TestResult),
  )
}

Constructors

  • RunStarted(total: Int)

    The run is starting, and this many tests will be attempted.

  • TestFinished(
      completed: Int,
      total: Int,
      result: types.TestResult,
    )

    One test finished (pass/fail/skip/timeout/setup failure).

    completed is 1-based and increases monotonically until it reaches total.

  • HookStarted(
      kind: HookKind,
      scope: List(String),
      test_name: option.Option(String),
    )

    A hook is about to run.

  • HookFinished(
      kind: HookKind,
      scope: List(String),
      test_name: option.Option(String),
      outcome: HookOutcome,
    )

    A hook finished running.

  • RunFinished(
      completed: Int,
      total: Int,
      results: List(types.TestResult),
    )

    The run finished. completed should equal total.

    results are in traversal order (deterministic), regardless of parallel execution.

Results reporters format the end-of-run results into one output block each.

They are executed in the order provided to runner.results_reporters(...).

pub type ResultsReporter {
  Bdd(BddReporterConfig)
  Json(JsonReporterConfig)
}

Constructors

Search Document