Rust runs functions marked with #[test] as tests. This example puts a unit test for an addition function in a #[cfg(test)] module.
| |
cargo test builds and runs the package tests. Passing tests show ok, and the summary includes test result: ok.
| |
If an assertion fails, that test is marked FAILED and Cargo exits with an error. Paths, line numbers, and timings vary by environment and Rust version.
