done with ch11
This commit is contained in:
parent
5015699e0d
commit
a288b75401
@ -3,4 +3,8 @@ name = "adder"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# [lib]
|
||||
# name="lib"
|
||||
# path="src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
|
11
ch11/adder/tests/common/mod.rs
Normal file
11
ch11/adder/tests/common/mod.rs
Normal file
@ -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
|
||||
}
|
15
ch11/adder/tests/integration_test.rs
Normal file
15
ch11/adder/tests/integration_test.rs
Normal file
@ -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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user