cargo test <testname_substring?>cargo test -- --show-outputcargo test -- --ignoredcargo test -- --test-threads=1
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn happy_path() {
let result = add(2, 2);
assert_eq!(result, 4);
}
#[test]
fn greeting_contains_name() {
let result = greeting("Carol");
assert!(
result.contains("Carol"),
"Greeting did not contain name, value was `{result}`"
);
}
#[test]
#[should_panic(expected = "less than or equal to 100")]
fn greater_than_100() {
Guess::new(200);
}
#[test]
#[ignore]
fn expensive_test() {
// code that takes an hour to run
}
}