Skip to content

Commit c26703b

Browse files
committed
document of shared modules for integration tests
1 parent d71f9f6 commit c26703b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/doc/book/testing.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ fn it_works() {
395395
```
396396

397397
This looks similar to our previous tests, but slightly different. We now have
398-
an `extern crate adder` at the top. This is because the tests in the `tests`
399-
directory are an entirely separate crate, and so we need to import our library.
398+
an `extern crate adder` at the top. This is because each test in the `tests`
399+
directory is an entirely separate crate, and so we need to import our library.
400400
This is also why `tests` is a suitable place to write integration-style tests:
401401
they use the library like any other consumer of it would.
402402

@@ -429,6 +429,11 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
429429
Now we have three sections: our previous test is also run, as well as our new
430430
one.
431431

432+
Cargo will ignore files in subdirectories of the `tests/` directory.
433+
Therefore shared modules in integrations tests are possible.
434+
For example `tests/common/mod.rs` is not seperatly compiled by cargo but can
435+
be imported in every test with `mod common;`
436+
432437
That's all there is to the `tests` directory. The `tests` module isn't needed
433438
here, since the whole thing is focused on tests.
434439

0 commit comments

Comments
 (0)