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
47
47
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
48
48
```
49
49
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
52
52
functions, importing and using it within tests.
53
53
54
- File ` tests/common.rs ` :
54
+ File ` tests/common/mod .rs ` :
55
55
56
56
``` rust,ignore
57
57
pub fn setup() {
@@ -74,8 +74,9 @@ fn test_add() {
74
74
}
75
75
```
76
76
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.
79
80
80
81
[ unit ] : unit_testing.md
81
82
[ mod ] : ../mod.md
You can’t perform that action at this time.
0 commit comments