January 2019
Beginner to intermediate
554 pages
13h 31m
English
As is often the case with integration tests, there is some setup and teardown-related code that we might need to put in place before we can actually run our tests. You usually want them to be shared by all of the files in the tests/ directory. For sharing code, we can use modules by either creating them as a directory that shares common code, or use a module foo.rs and declare in our integration test files that we depend on it by putting a mod declaration. So, in our preceding tests/ directory, we added a common.rs module that has two functions called setup and teardown:
// integration_test/tests/common.rspub fn setup() { println!("Setting up fixtures");}pub fn teardown() { println!("Tearing down");}
In both of our functions, ...
Read now
Unlock full access