diff --git a/lib/ex_unit/lib/ex_unit.ex b/lib/ex_unit/lib/ex_unit.ex index 4c60a495cb2..fbe3b40eb22 100644 --- a/lib/ex_unit/lib/ex_unit.ex +++ b/lib/ex_unit/lib/ex_unit.ex @@ -103,6 +103,8 @@ defmodule ExUnit do * `:logs` - the captured logs * `:parameters` - the test parameters + When a test has finished, the following fields are added for consumption by `ExUnit.Formatter` callbacks: + * `:test_pid` - the PID that the test was running on """ defstruct [:name, :case, :module, :state, time: 0, tags: %{}, logs: "", parameters: %{}] diff --git a/lib/ex_unit/lib/ex_unit/runner.ex b/lib/ex_unit/lib/ex_unit/runner.ex index 29bd90d3716..4adda30588a 100644 --- a/lib/ex_unit/lib/ex_unit/runner.ex +++ b/lib/ex_unit/lib/ex_unit/runner.ex @@ -456,6 +456,7 @@ defmodule ExUnit.Runner do end defp receive_test_reply(test, test_pid, test_ref, timeout) do + test = Map.put(test, :test_pid, test_pid) receive do {^test_pid, :test_finished, test} -> Process.demonitor(test_ref, [:flush])