flutter_gherkin icon indicating copy to clipboard operation
flutter_gherkin copied to clipboard

Can we accept exceptions?

Open AFASbart opened this issue 3 years ago • 5 comments

Is it possible to 'accept' exceptions? For an action a custom Exception gets thrown, and that makes the step fail, but I want the exception to be thrown...

Is it possible to say that that specific exception is allowed to be thrown? @jonsamwell

AFASbart avatar Dec 07 '21 15:12 AFASbart

This is a tricky one of a step performs an action and unlike a unit test does not wrap the code being executed rather perform an action on say a UI element that executes the code that would throw an exception.

That being said I you might be able to do something with this https://api.flutter.dev/flutter/flutter_test/WidgetTester/takeException.html?

jonsamwell avatar Dec 08 '21 21:12 jonsamwell

I never had success with takeException in e2e compared to WidgetTests, hopefully it works in later versions of flutter maybe?

vrnvorona avatar Dec 15 '21 13:12 vrnvorona

Is this working in 3.0.0-rc.17?

jonsamwell avatar Jul 25 '22 07:07 jonsamwell

I will check tomorrow, thanks

vrnvorona avatar Jul 25 '22 09:07 vrnvorona

It seems to work, at least with my testing. To emulate this I added exception throw on button which navigates screen, and added takeException in step which presses this button, and it caught it just fine (even recorded in variable as it should so we can test for planned Exceptions) and then proceeded next.

vrnvorona avatar Jul 27 '22 07:07 vrnvorona