What processes started within a test are automatically cleaned up?

The doc at https://hexdocs.pm/ex_unit/ExUnit.Callbacks.html gives a lot of good information about some of the auto cleanup functionality of ExUnit.

I’m clear that anything started in a setup/test block with start_supervised/2 will be auto-cleaned in an orderly fashion, and it also appears that when using Ecto.Adapters.SQL.Sandbox data is also automagically cleaned up. All very nice :slight_smile:

What about this scenario though:

  test "ping returns pong" do
    {:ok, pid} = DynamicSupervisor.start_child(Foo.Supervisor, {Foo.Worker, []})
    assert GenServer.call(pid, :ping) == :pong
  end

Does ExUnit magically clean up that Foo.Worker process that gets started, or am I responsible for cleaning that up myself? Guessing the latter…

1 Like