ExUnitJSON.Formatter (ex_unit_json v0.4.2)

Copy Markdown View Source

ExUnit formatter that outputs test results as JSON.

This GenServer receives events from ExUnit during test execution and accumulates results. When the test suite finishes, it outputs a complete JSON document with all test results and summary statistics.

Usage

Configure ExUnit to use this formatter:

ExUnit.configure(formatters: [ExUnitJSON.Formatter])

Or use the mix test.json task which configures this automatically.

Events Handled

  • {:suite_started, opts} - Captures seed and start time
  • {:test_finished, test} - Accumulates individual test results
  • {:module_finished, module} - Tracks module-level failures (setup_all)
  • {:suite_finished, times_us} - Outputs final JSON

Summary

Types

t()

Formatter state accumulating test results during a test run

Functions

Returns a specification to start this module under a supervisor.

Types

t()

@type t() :: %ExUnitJSON.Formatter{
  modules: [map()],
  opts: keyword(),
  seed: non_neg_integer() | nil,
  start_time: integer() | nil,
  tests: [map()]
}

Formatter state accumulating test results during a test run

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.