rust-course/assets/writing-material/posts/tests/integration_test.md

19 lines
314 B

3 years ago
Cargo looks for integration tests in `tests` directory next to `src`.
File `src/lib.rs`:
```rust
// Define this in a crate called `adder`.
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
```
File with `test: tests/integration_test.rs`:
```rust
#[test]
fn test_add() {
assert_eq!(adder::add(3, 2), 5);
}
```