Usage
add #[test] on the line before fn. When you run your tests with the cargo test command, Rust builds a test runner binary that runs the functions annotated with the test attribute and reports on whether each test function passes or fails.
the#[ignore] attribute to exclude some tests
Cargo Command
1 | cargo test |
Example
Case: Hello
1 |
|
1 | running 1 test |
panic
1 |
|
should panic
1 | pub fn divide_non_zero_result(a: u32, b: u32) -> u32 { |