Skip to content

Commit 1071e07

Browse files
committed
Add note about breaking up failure cases in tests
When writing tests for failure cases, we need to break up each case into a separate code block so that each is tested properly. Let's describe this in our authoring guidelines.
1 parent f45f40d commit 1071e07

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/authoring.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Rust examples are tested via rustdoc, and should include the appropriate annotat
5454
* `ignore` --- The example shouldn't be built or tested. This should be avoided if possible. Usually this is only necessary when the testing framework does not support it (such as external crates or modules, or a proc-macro), or it contains pseudo-code which is not valid Rust. An HTML comment such as `<!-- ignore: requires extern crate -->` should be placed before the example to explain why it is ignored.
5555
* `Exxxx` --- If the example is expected to fail to compile with a specific error code, include that code so that rustdoc will check that the expected code is used.
5656

57+
When demonstrating success cases, many such cases may be included in a single code block. For failure cases, however, each example must appear in a separate code block so that the tests can ensure that each case indeed fails and fails with the appropriate error code or codes.
58+
5759
See the [rustdoc documentation] for more detail.
5860

5961
[rustdoc documentation]: https://doc.rust-lang.org/rustdoc/documentation-tests.html

0 commit comments

Comments
 (0)