Unit Tests
Rust and Cargo come with a simple unit test framework. Tests are marked with
#[test]
. Unit tests are often put in a nested tests
module, using
#[cfg(test)]
to conditionally compile them only when building tests.
- This lets you unit test private helpers.
- The
#[cfg(test)]
attribute is only active when you runcargo test
.