-
Notifications
You must be signed in to change notification settings - Fork 40
Result::Err is not interpreted as a failure #50
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
In Rust 2018 test can return a Result type, with Result::Err being interpreted as a failure. However with parameterised tests returned errors are treated as passing. While this can be fixed by specifying an expected value, it is unintuitive.
Example:
fn should_equal_4(num: i32) -> Result<(), ()> {
if num == 4 {
Ok(())
} else {
Err(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use test_case::test_case;
#[test_case(4; "Passing")]
#[test_case(5; "Failing")]
fn with_params(num: i32) -> Result<(), ()> {
should_equal_4(num)?;
Ok(())
}
#[test]
fn is_4() -> Result<(), ()> {
should_equal_4(4)?;
Ok(())
}
#[test]
fn is_5() -> Result<(), ()> {
should_equal_4(5)?;
Ok(())
}
}
Expected: Both tests::with_params::failing() and is_5() fail.
Actual: Only is_5() fails.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working