From 3afd582a96f7ecc4e9c21ba0ed3dad3fda1c6421 Mon Sep 17 00:00:00 2001 From: Peteris Ledins Date: Wed, 19 Jul 2023 22:56:39 +0300 Subject: [PATCH 1/2] Refer to `--exact` for running exact one test --- src/ch11-02-running-tests.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ch11-02-running-tests.md b/src/ch11-02-running-tests.md index 406b06e681..b02bfe10c3 100644 --- a/src/ch11-02-running-tests.md +++ b/src/ch11-02-running-tests.md @@ -128,6 +128,10 @@ Only the test with the name `one_hundred` ran; the other two tests didn’t matc that name. The test output lets us know we had more tests that didn’t run by displaying `2 filtered out` at the end. +If a test name is a substring of another test, we can use `-- --exact` argument, +referring to test function with full path, for example +`cargo test tests::one_hundred -- --exact`. + We can’t specify the names of multiple tests in this way; only the first value given to `cargo test` will be used. But there is a way to run multiple tests. From 871ace83d1b8a029a5fe932b9078a88e8fc6fb55 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Wed, 27 Nov 2024 07:47:06 -0700 Subject: [PATCH 2/2] Link to the rustc book for docs about `cargo test -- ` --- src/ch11-02-running-tests.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ch11-02-running-tests.md b/src/ch11-02-running-tests.md index b02bfe10c3..1c9a1a35da 100644 --- a/src/ch11-02-running-tests.md +++ b/src/ch11-02-running-tests.md @@ -13,7 +13,12 @@ binary. To separate these two types of arguments, you list the arguments that go to `cargo test` followed by the separator `--` and then the ones that go to the test binary. Running `cargo test --help` displays the options you can use with `cargo test`, and running `cargo test -- --help` displays the options you -can use after the separator. +can use after the separator. Those options are also documented in [the “Tests” +section][tests] of the [the rustc book][rustc]. + +[tests]: https://doc.rust-lang.org/rustc/tests/index.html +[rustc]: https://doc.rust-lang.org/rustc/index.html + ### Running Tests in Parallel or Consecutively @@ -128,10 +133,6 @@ Only the test with the name `one_hundred` ran; the other two tests didn’t matc that name. The test output lets us know we had more tests that didn’t run by displaying `2 filtered out` at the end. -If a test name is a substring of another test, we can use `-- --exact` argument, -referring to test function with full path, for example -`cargo test tests::one_hundred -- --exact`. - We can’t specify the names of multiple tests in this way; only the first value given to `cargo test` will be used. But there is a way to run multiple tests.