-
| In some cases I want to assert that a particular error was returned when I perform a step. For instance in a toy example I would love to have: Scenario: Divide by n Given I start with 6 When I divide by 6 Then I have 1 Scenario: Divide by 0 Given I start with 6 When I divide by 0 Then I get a "divide by 0" errorHow would I implement an expected failure? Ideally the Should I be caching the result of the pub struct MySpecialInteger(u64); #[derive(Debug, Default, World)] pub struct MyWorld{ number: MySpecialInteger, result: Result<u64, MyNumberError> } #[when(r"I divide by (\d+)"]) fn divide_by_n(world: &mut MyWorld, num: u64) { world.result = world.number.0 / num; // pretend this produces a Result } // pseudocode #[then(r"I get a (\s+) error"]) fn divide_by_n(world: &mut MyWorld, expected_message: &str) { assert!(world.result.message.contains(expected_message)); }I could also have a then step which is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You are absolutely right, the recommended way is to store whole |
Beta Was this translation helpful? Give feedback.
You are absolutely right, the recommended way is to store whole
Results onwhensteps and assert them onthens.