# `Juggernaut.Peer.Formatter`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/peer/formatter.ex#L1)

The ExUnit formatter of a worker's jobs (design notes §10.5): it prints nothing and
sends each finished test, as a small map, to the process that runs the job.

ExUnit starts a formatter for every run with the run's configuration, where the job
puts `juggernaut_collector` (the pid to send to) and `juggernaut_job` (a reference
that tags every message, so a message of an earlier job is never taken for this one's).
Messages:

  * `{:juggernaut_started, job, {module, name}}` for each test ExUnit starts;
  * `{:juggernaut_test, job, outcome}` for each finished test (see `outcome/1`). Once
    `max_failures` is reached, a test that finishes afterwards (in another async
    module, already running) is not reported finished, only started
    (`docs/dependencies/exunit.md`, "max_failures");
  * `{:juggernaut_max_failures, job}` when ExUnit stops at `max_failures`;
  * `{:juggernaut_suite_finished, job}` last.

ExUnit stops its formatters before `ExUnit.run/1` returns, and a formatter handles its
casts in order, so every message has been sent when the run returns.

This module runs inside workers and is never mutated.

# `outcome`

```elixir
@type outcome() :: %{
  id: {module(), atom()},
  state: :passed | :failed | :excluded | :skipped | :invalid,
  time_us: non_neg_integer(),
  failure: nil | %{kind: atom(), exception: module() | nil, message: String.t()}
}
```

A finished test as the job reports it.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `outcome`

```elixir
@spec outcome(ExUnit.Test.t()) :: outcome()
```

A finished `ExUnit.Test` as a small map that crosses the peer connection cheaply.

---

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