From 405c1c7e9b3e4d488dd85f0bcb7b6cd7b3a0e9fa Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 2 Nov 2015 11:21:30 -0800 Subject: [PATCH 1/3] Docs: Clarify what `cargo test` compiles vs. runs --- src/doc/manifest.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/manifest.md b/src/doc/manifest.md index c00f33c0241..d30001fef81 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -424,11 +424,11 @@ your tests to protect them from bitrotting. When you run `cargo test`, Cargo will: -* Compile your library's unit tests, which are in files reachable from +* Compile and run your library's unit tests, which are in files reachable from `lib.rs`. Any sections marked with `#[cfg(test)]` will be included. -* Compile your library’s documentation tests, which are embedded inside - of documentation blocks. -* Compile your library's integration tests, which are located in +* Compile and run your library’s documentation tests, which are embedded + inside of documentation blocks. +* Compile and run your library's integration tests, which are located in `tests`. Files in `tests` load in your library by using `extern crate ` like any other code that depends on it. * Compile your library's examples. From 6069fe14441c9843fdd21fce66047aae258d30f1 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 2 Nov 2015 11:32:26 -0800 Subject: [PATCH 2/3] Expand documentation on integration tests --- src/doc/manifest.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/doc/manifest.md b/src/doc/manifest.md index d30001fef81..cebdee06146 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -428,11 +428,22 @@ When you run `cargo test`, Cargo will: `lib.rs`. Any sections marked with `#[cfg(test)]` will be included. * Compile and run your library’s documentation tests, which are embedded inside of documentation blocks. -* Compile and run your library's integration tests, which are located in - `tests`. Files in `tests` load in your library by using `extern crate - ` like any other code that depends on it. +* Compile and run your library's [integration tests](#integration-tests). * Compile your library's examples. +## Integration tests + +Each file in `tests/*.rs` is an integration test. When you run `cargo test`, +Cargo will compile each of these files as a separate crate. The crate can link +to your library by using `extern crate `, like any other code +that depends on it. + +Cargo will not automatically compile files inside subdirectories of `tests`, +but an integration test can import modules from these directories as usual. +For example, if you want several integration tests to share some code, you can +put the shared code in `tests/common/mod.rs` and then put `mod common;` in +each of the test files. + # Configuring a target All of the `[[bin]]`, `[lib]`, `[[bench]]`, and `[[test]]` sections support From 5cf61206f2e4ae37ae39d4b8342880d5dad2dd53 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 2 Nov 2015 11:33:34 -0800 Subject: [PATCH 3/3] Docs: Mention the [[example]] section --- src/doc/manifest.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doc/manifest.md b/src/doc/manifest.md index cebdee06146..f8dc7b3aa31 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -446,10 +446,11 @@ each of the test files. # Configuring a target -All of the `[[bin]]`, `[lib]`, `[[bench]]`, and `[[test]]` sections support -similar configuration for specifying how a target should be built. The example -below uses `[lib]`, but it also applies to all other sections as well. All -values listed are the defaults for that option unless otherwise specified. +All of the `[[bin]]`, `[lib]`, `[[bench]]`, `[[test]]`, and `[[example]]` +sections support similar configuration for specifying how a target should be +built. The example below uses `[lib]`, but it also applies to all other +sections as well. All values listed are the defaults for that option unless +otherwise specified. ```toml [package]