File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -745,6 +745,7 @@ defmodule ExUnit.Assertions do
745745
746746 @ doc """
747747 Asserts `expression` will throw a value.
748+
748749 Returns the thrown value or fails otherwise.
749750
750751 ## Examples
@@ -758,11 +759,19 @@ defmodule ExUnit.Assertions do
758759
759760 @ doc """
760761 Asserts `expression` will exit.
761- Returns the exit status/message or fails otherwise.
762+
763+ Returns the exit status/message of the current process or fails otherwise.
762764
763765 ## Examples
764766
765767 assert catch_exit(exit 1) == 1
768+
769+ To assert exits from linked processes started from the test, trap exits
770+ with `Process.flag/2` and assert the exit message with `assert_received/2`.
771+
772+ Process.flag(:trap_exit, true)
773+ pid = spawn_link(fn -> Process.exit(self(), :normal) end)
774+ assert_receive {:EXIT, ^pid, :normal}
766775
767776 """
768777 defmacro catch_exit ( expression ) do
@@ -771,6 +780,7 @@ defmodule ExUnit.Assertions do
771780
772781 @ doc """
773782 Asserts `expression` will cause an error.
783+
774784 Returns the error or fails otherwise.
775785
776786 ## Examples
You can’t perform that action at this time.
0 commit comments