Temper.Record (temper v0.2.0)

Copy Markdown View Source

One recorded test outcome — the unit Temper's history is made of.

from_test/2 maps a finished %ExUnit.Test{} plus the run's Temper.RunContext into a flat, serializable record: test identity (module + name), location and tags, the outcome status, timing, and — for failures — a failure signature (exception kind, truncated message, and a stable hash of the full message) so that later analysis can group distinct flake modes.

This module is part of Temper's functional core: data in, data out, no side effects.

Summary

Types

Signature of a failure, used to group flake modes.

Outcome of a single test, mirroring ExUnit.Test states.

t()

Functions

Builds a record from a finished ExUnit test and the current run context.

Types

failure()

@type failure() :: %{kind: String.t(), message: String.t(), hash: String.t()}

Signature of a failure, used to group flake modes.

status()

@type status() :: :passed | :failed | :skipped | :excluded | :invalid

Outcome of a single test, mirroring ExUnit.Test states.

t()

@type t() :: %Temper.Record{
  async: boolean() | nil,
  context: Temper.RunContext.t(),
  failure: failure() | nil,
  file: String.t() | nil,
  line: pos_integer() | nil,
  module: String.t(),
  name: String.t(),
  status: status(),
  test_type: String.t() | nil,
  time_us: non_neg_integer() | nil
}

Functions

from_test(test, context)

@spec from_test(ExUnit.Test.t(), Temper.RunContext.t()) :: t()

Builds a record from a finished ExUnit test and the current run context.

The mapping from test.state to :status:

  • nil:passed
  • {:failed, failures}:failed, with a failure signature taken from the first failure
  • {:skipped, _}, {:excluded, _}, {:invalid, _} → the corresponding atom

:module and :name together identify the test across runs; :file, :line, :async and :test_type come from test.tags. :time_us is ExUnit's measured runtime in microseconds (nil for tests that never ran, e.g. excluded ones).