File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -47,11 +47,11 @@ running 0 tests
4747test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
4848```
4949
50- Each Rust source file in the ` tests ` directory is compiled as a separate crate. One
51- way of sharing some code between integration tests is making a module with public
50+ Each Rust source file in the ` tests ` directory is compiled as a separate crate. In
51+ order to share some code between integration tests we can make a module with public
5252functions, importing and using it within tests.
5353
54- File ` tests/common.rs ` :
54+ File ` tests/common/mod .rs ` :
5555
5656``` rust,ignore
5757pub fn setup() {
@@ -74,8 +74,9 @@ fn test_add() {
7474}
7575```
7676
77- Modules with common code follow the ordinary [ modules] [ mod ] rules, so it's ok to
78- create common module as ` tests/common/mod.rs ` .
77+ Creating the module as ` tests/common.rs ` also works, but is not recommended
78+ because the test runner will treat the file as a test crate and try to run tests
79+ inside it.
7980
8081[ unit ] : unit_testing.md
8182[ mod ] : ../mod.md
You can’t perform that action at this time.
0 commit comments