How to handle errors in tests

Handle test errors by using unwrap() or expect() to panic immediately on failure.

Handle errors in tests by using unwrap() on Result types to panic immediately on failure, or expect() to provide a custom error message. This ensures your test fails fast if the operation does not succeed.

#[test]
fn test_example() {
    let result = Some(42);
    // Panics if result is None, failing the test
    let value = result.expect("Expected a value, but got None");
    assert_eq!(value, 42);
}