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
745
745
746
746
@ doc """
747
747
Asserts `expression` will throw a value.
748
+
748
749
Returns the thrown value or fails otherwise.
749
750
750
751
## Examples
@@ -758,11 +759,19 @@ defmodule ExUnit.Assertions do
758
759
759
760
@ doc """
760
761
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.
762
764
763
765
## Examples
764
766
765
767
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}
766
775
767
776
"""
768
777
defmacro catch_exit ( expression ) do
@@ -771,6 +780,7 @@ defmodule ExUnit.Assertions do
771
780
772
781
@ doc """
773
782
Asserts `expression` will cause an error.
783
+
774
784
Returns the error or fails otherwise.
775
785
776
786
## Examples
You can’t perform that action at this time.
0 commit comments