Glossary: Rust Beyond the Basics
#[test]
Also written: test, tests, #[cfg(test)], should_panic
An attribute marking a function as a test that fails if it panics. `#[cfg(test)]` compiles a module only when testing, and `#[should_panic]` makes a test pass only if the code panics.