In Perl, we put our tests in a
t directory and then
prove -l will run them. Similarly, Rust has a
tests directory and
cargo test will run the tests there.
But Rust does this mostly for integration tests. Unit tests are typically put right in the same file as the code.
#[cfg(test)] macro tells cargo to run those tests when it is called as
cargo test, but to ignore them when it is called as
cargo build or