Skip to content

Commit

Permalink
document of shared modules for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JDemler committed Jun 3, 2016
1 parent d71f9f6 commit c26703b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/doc/book/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ fn it_works() {
```

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

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

Cargo will ignore files in subdirectories of the `tests/` directory.
Therefore shared modules in integrations tests are possible.
For example `tests/common/mod.rs` is not seperatly compiled by cargo but can
be imported in every test with `mod common;`

That's all there is to the `tests` directory. The `tests` module isn't needed
here, since the whole thing is focused on tests.

Expand Down

0 comments on commit c26703b

Please sign in to comment.