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
+27-4Lines changed: 27 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,25 @@
1
1
# Testing attributes
2
2
3
+
r[attributes.testing]
4
+
3
5
The following [attributes] are used for specifying functions for performing
4
6
tests. Compiling a crate in "test" mode enables building the test functions
5
7
along with a test harness for executing the tests. Enabling the test mode also
6
8
enables the [`test` conditional compilation option].
7
9
8
10
## The `test` attribute
9
11
10
-
The *`test` attribute* marks a function to be executed as a test. These
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 implement the [`Termination`] trait, for example:
12
+
r[attributes.testing.test]
13
+
14
+
15
+
r[attributes.testing.test.general]
16
+
The *`test` attribute* marks a function to be executed as a test.
17
+
18
+
r[attributes.testing.test.enabled]
19
+
These functions are only compiled when in test mode.
20
+
21
+
r[attributes.testing.test.restriction]
22
+
Test functions must be free, monomorphic functions that take no arguments, and the return type must implement the [`Termination`] trait, for example:
13
23
14
24
*`()`
15
25
*`Result<T, E> where T: Termination, E: Debug`
@@ -21,6 +31,7 @@ monomorphic functions that take no arguments, and the return type must implement
21
31
> Note: The test mode is enabled by passing the `--test` argument to `rustc`
22
32
> or using `cargo test`.
23
33
34
+
r[attributes.testing.success]
24
35
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.
25
36
In particular:
26
37
* Tests that return `()` pass as long as they terminate and do not panic.
0 commit comments