# `Surfex.ExUnitFormatter`
[🔗](https://github.com/dcoai/surfex/blob/v0.13.0/lib/surfex/ex_unit_formatter.ex#L1)

An ExUnit formatter that records test evidence (`Surfex.Evidence`): for each test that
ran, whether it passed, at its exact version, with the versions of the code it reaches:
what it calls, and what that code calls (`Surfex.Scan.reach/1`).

Add it beside the usual formatter, in `test/test_helper.exs`:

    ExUnit.start(formatters: [ExUnit.CLIFormatter, Surfex.ExUnitFormatter])

At the start of the suite it scans the project as `mix surfex.status` does: the tests
`tests:` names in `.surfex.exs`, and the code. A finished test is matched to its scanned
record by file and line, so a test a comprehension generates counts for the record that
defines it. When a record's test ran more than once in a run (one per case), it failed
if any case failed. An excluded or skipped test is recorded as such, with no code
versions, so a run that leaves a test out is told apart from one where it didn't run.
Each record carries how long the test's cases took, in microseconds (`duration`), and a
failed one what its first failing case showed (`failure`, `t:Surfex.Evidence.failure/0`).
Invalid tests, and tests outside `tests:`, record nothing. When the suite finishes, the run's records are appended to
`Surfex.Evidence.path/1` under `_build`: scratch data, never committed.

In a project that keeps a log (`.surfex/`), the run's pass/fail **transitions** are also
appended to `.surfex/transitions.log`, which is committed: one line per test whose result
flipped (§17). In CI, set `SURFEX_TRANSITIONS_OUT=PATH` and they go to `PATH` instead, a
job artifact, judged against the committed file: the job never writes the checkout, and
`mix surfex.failures --ingest PATH` brings them in.

It never touches the relation log. Evidence justifies confirmations only when someone
asks for them (`mix surfex.confirm --evidence`).

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
