@@ -3,8 +3,9 @@ defmodule ExUnit.Callbacks do
3
3
Defines ExUnit callbacks.
4
4
5
5
This module defines the `setup/1`, `setup/2`, `setup_all/1`, and
6
- `setup_all/2` callbacks, as well as the `on_exit/2`, `start_supervised/2`,
7
- `stop_supervised/1` and `start_link_supervised!/2` functions.
6
+ `setup_all/2` macros, as well as process lifecycle and management
7
+ functions, such as `on_exit/2`, `start_supervised/2`, `stop_supervised/1`
8
+ and `start_link_supervised!/2`.
8
9
9
10
The setup callbacks may be used to define [test fixtures](https://en.wikipedia.org/wiki/Test_fixture#Software)
10
11
and run any initialization code which help bring the system into a known
@@ -56,13 +57,15 @@ defmodule ExUnit.Callbacks do
56
57
57
58
## Context
58
59
59
- If `setup_all` or `setup` return a keyword list, a map, or a tuple in the shape
60
- of `{:ok, keyword() | map()}`, the keyword list or map will be merged into the
61
- current context and will be available in all subsequent `setup_all`,
62
- `setup`, and the `test` itself.
60
+ `setup_all` or `setup` may return one of:
63
61
64
- Returning `:ok` leaves the context unchanged (in `setup` and `setup_all`
65
- callbacks).
62
+ * the atom `:ok`
63
+ * a keyword list or map
64
+ * a tuple in the shape of `{:ok, keyword() | map()}`
65
+
66
+ If a keyword list or map is returned, it be merged into the current context
67
+ and will be available in all subsequent `setup_all`, `setup`, and the `test`
68
+ itself.
66
69
67
70
Returning anything else from `setup_all` will force all tests to fail,
68
71
while a bad response from `setup` causes the current test to fail.
@@ -728,7 +731,7 @@ defmodule ExUnit.Callbacks do
728
731
729
732
defp raise_merge_failed! ( mod , kind , return_value ) do
730
733
raise "expected ExUnit #{ kind } callback in #{ inspect ( mod ) } to " <>
731
- "return :ok | keyword | map, got #{ inspect ( return_value ) } instead"
734
+ "return the atom :ok, a keyword, or a map, got #{ inspect ( return_value ) } instead"
732
735
end
733
736
734
737
defp raise_merge_reserved! ( mod , kind , key , value ) do
0 commit comments