fix(hook): ensured `AttachScreenshotOnFailedStepHook` cannot throw an unhandled exception causing the test run to stop
This commit is contained in:
parent
ff539c0a58
commit
32018a4cc8
|
@ -1,5 +1,6 @@
|
||||||
## [1.1.7+3] - 08/01/2019
|
## [1.1.7+3] - 08/01/2019
|
||||||
* Added retry logic to the Futter driver connect call to handle the seemingly random connection failures
|
* Added retry logic to the Futter driver connect call to handle the seemingly random connection failures
|
||||||
|
* Ensured `AttachScreenshotOnFailedStepHook` cannot throw an unhandled exception causing the test run to stop
|
||||||
|
|
||||||
## [1.1.7+2] - 07/01/2019
|
## [1.1.7+2] - 07/01/2019
|
||||||
* Increased the Flutter driver reconnection delay to try and overcome some driver to app connection issues on slower machines
|
* Increased the Flutter driver reconnection delay to try and overcome some driver to app connection issues on slower machines
|
||||||
|
|
|
@ -7,12 +7,19 @@ import '../flutter_world.dart';
|
||||||
class AttachScreenshotOnFailedStepHook extends Hook {
|
class AttachScreenshotOnFailedStepHook extends Hook {
|
||||||
@override
|
@override
|
||||||
Future<void> onAfterStep(
|
Future<void> onAfterStep(
|
||||||
World world, String step, StepResult stepResult) async {
|
World world,
|
||||||
|
String step,
|
||||||
|
StepResult stepResult,
|
||||||
|
) async {
|
||||||
if (stepResult.result == StepExecutionResult.fail ||
|
if (stepResult.result == StepExecutionResult.fail ||
|
||||||
stepResult.result == StepExecutionResult.error ||
|
stepResult.result == StepExecutionResult.error ||
|
||||||
stepResult.result == StepExecutionResult.timeout) {
|
stepResult.result == StepExecutionResult.timeout) {
|
||||||
final screenshotData = await takeScreenshot(world);
|
try {
|
||||||
world.attach(screenshotData, 'image/png', step);
|
final screenshotData = await takeScreenshot(world);
|
||||||
|
world.attach(screenshotData, 'image/png', step);
|
||||||
|
} catch (e, st) {
|
||||||
|
world.attach('Failed to take screenshot\n$e\n$st', 'text/plain', step);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue