]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/rust-by-example/src/testing/integration_testing.md
New upstream version 1.64.0+dfsg1
[rustc.git] / src / doc / rust-by-example / src / testing / integration_testing.md
index 0ac77588c3547962abd104c128a07e259a4b3562..60406e30238070c28b6350b5692bbc04c51335e2 100644 (file)
@@ -47,11 +47,11 @@ running 0 tests
 test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
 ```
 
-Each Rust source file in the `tests` directory is compiled as a separate crate. One
-way of sharing some code between integration tests is making a module with public
+Each Rust source file in the `tests` directory is compiled as a separate crate. In
+order to share some code between integration tests we can make a module with public
 functions, importing and using it within tests.
 
-File `tests/common.rs`:
+File `tests/common/mod.rs`:
 
 ```rust,ignore
 pub fn setup() {
@@ -74,8 +74,9 @@ fn test_add() {
 }
 ```
 
-Modules with common code follow the ordinary [modules][mod] rules, so it's ok to
-create common module as `tests/common/mod.rs`.
+Creating the module as `tests/common.rs` also works, but is not recommended
+because the test runner will treat the file as a test crate and try to run tests
+inside it.
 
 [unit]: unit_testing.md
 [mod]: ../mod.md