Unit Tests
Test Functions
Controlling How Tests Are Run
Test Organization
Unit Tests:
- Inside the same module as the tested code
- annotated with
#[cfg(test)]
- can test private code by default
- import tested code with
super::*
- compiled only with
cargo test
Integration tests:
- inside top level
tests
folder - need to import tested code by crate name
- place util functions in a
mod.rs
to avoid testing them, e.g:tests/common/mod.rs
- compiled only with
cargo test