Skip to content

Commit 2c9cfd6

Browse files
committed
doc: add more link references for tests guide
- Mention that in `src/` Cargo also collect doc tests. - Remove outdated statement: Cargo no longer tests examples by default. - Add a link to "Cargo Targets: Tests" to help people learn about it.
1 parent 370a481 commit 2c9cfd6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/doc/src/guide/tests.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Cargo can run your tests with the `cargo test` command. Cargo looks for tests
44
to run in two places: in each of your `src` files and any tests in `tests/`.
5-
Tests in your `src` files should be unit tests, and tests in `tests/` should be
6-
integration-style tests. As such, you’ll need to import your crates into
7-
the files in `tests`.
5+
Tests in your `src` files should be unit tests and [documentation tests].
6+
Tests in `tests/` should be integration-style tests. As such, you’ll need to
7+
import your crates into the files in `tests`.
88

99
Here's an example of running `cargo test` in our [package][def-package], which
1010
currently has no tests:
@@ -31,10 +31,14 @@ $ cargo test foo
3131

3232
This will run any test with `foo` in its name.
3333

34-
`cargo test` runs additional checks as well. It will compile any
35-
examples you’ve included and will also test the examples in your
36-
documentation. Please see the [testing guide][testing] in the Rust
37-
documentation for more details.
34+
`cargo test` runs additional checks as well. It will compile any examples
35+
you’ve included to ensure they are still compiles. It also run documentation
36+
tests to ensure your code samples from documentation comments compiles.
37+
Please see the [testing guide][testing] in the Rust documentation for a general
38+
view of writing and organizing tests. See [Cargo Targets: Tests] to learn more
39+
about different styles of tests in Cargo.
3840

41+
[documentation tests]: ../../rustdoc/write-documentation/documentation-tests.html
3942
[def-package]: ../appendix/glossary.md#package '"package" (glossary entry)'
4043
[testing]: ../../book/ch11-00-testing.html
44+
[Cargo Targets: Tests]: ../reference/cargo-targets.html#tests

0 commit comments

Comments
 (0)