You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/attributes/testing.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,26 +9,25 @@ enables the [`test` conditional compilation option].
9
9
10
10
The *`test` attribute* marks a function to be executed as a test. These
11
11
functions are only compiled when in test mode. Test functions must be free,
12
-
monomorphic functions that take no arguments, and the return type must be one
13
-
of the following:
12
+
monomorphic functions that take no arguments, and the return type must implement the [`Termination`] trait, for example:
14
13
15
14
*`()`
16
-
*`Result<(), E> where E: Error`
17
-
<!-- * `!` -->
18
-
<!-- * Result<!, E> where E: Error` -->
19
-
20
-
> Note: The implementation of which return types are allowed is determined by
21
-
> the unstable [`Termination`] trait.
15
+
*`Result<(), E> where E: Debug`
16
+
*`!`
17
+
<!-- * Result<!, E> where E: Debug` -->
22
18
23
19
<!-- If the previous section needs updating (from "must take no arguments"
24
20
onwards, also update it in the crates-and-source-files.md file -->
25
21
26
22
> Note: The test mode is enabled by passing the `--test` argument to `rustc`
27
23
> or using `cargo test`.
28
24
29
-
Tests that return `()` pass as long as they terminate and do not panic. Tests
30
-
that return a `Result<(), E>` pass as long as they return `Ok(())`. Tests that
31
-
do not terminate neither pass nor fail.
25
+
The test harness calls the returned value's [`report`] method, and classifies the test as passed or failed depending on whether the resulting [`ExitCode`] represents successful termination.
26
+
In particular:
27
+
* Tests that return `()` pass as long as they terminate and do not panic.
28
+
* Tests that return a `Result<(), E>` pass as long as they return `Ok(())`.
29
+
* Tests that return `ExitCode::SUCCESS` pass, and tests that return `ExitCode::FAILURE` fail.
30
+
* Tests that do not terminate neither pass nor fail.
0 commit comments