diff --git a/ch11/adder/Cargo.toml b/ch11/adder/Cargo.toml index e61cb12..2f47f56 100644 --- a/ch11/adder/Cargo.toml +++ b/ch11/adder/Cargo.toml @@ -3,4 +3,8 @@ name = "adder" version = "0.1.0" edition = "2021" +# [lib] +# name="lib" +# path="src/lib.rs" + [dependencies] diff --git a/ch11/adder/tests/common/mod.rs b/ch11/adder/tests/common/mod.rs new file mode 100644 index 0000000..f00413c --- /dev/null +++ b/ch11/adder/tests/common/mod.rs @@ -0,0 +1,11 @@ +// Having common appear in the test results with `running 0 tests` +// is suboptimal. To avoid this, make a file `tests/common/mod.rs` + +// Files in the subdirectories of the tests directory don't get compiled +// as separate crates or have sections in the test output. +// +// Can use this file from any of the integration test files as a module. + +pub fn setup() { + // setup code for specific library's tests would go here +} diff --git a/ch11/adder/tests/integration_test.rs b/ch11/adder/tests/integration_test.rs new file mode 100644 index 0000000..7c25315 --- /dev/null +++ b/ch11/adder/tests/integration_test.rs @@ -0,0 +1,15 @@ +// can run with just `cargo test` or +// $ cargo test --test integration_test +// for this file specifically + +use adder::add_two; + +mod common; + +#[test] +fn it_adds_two() { + common::setup(); + + let result = add_two(2); + assert_eq!(result, 4); +}