MDL-66979 behat: Handle driver stop failure properly

An case was found where the webdriver stop() call could fail in an
AfterScenario hook, leading to a complete rerun if no other errors were
experienced.
This commit is contained in:
Andrew Nicols
2021-01-28 15:07:52 +08:00
parent 058394a412
commit ebd36d2ac2
+18 -1
View File
@@ -660,7 +660,24 @@ EOF;
* @AfterScenario
*/
public function reset_webdriver_between_scenarios(AfterScenarioScope $scope) {
$this->getSession()->stop();
try {
$this->getSession()->stop();
} catch (Exception $e) {
$error = <<<EOF
Error while stopping WebDriver: %s (%d) '%s'
Attempting to continue with test run. Stacktrace follows:
%s
EOF;
error_log(sprintf(
$error,
get_class($e),
$e->getCode(),
$e->getMessage(),
format_backtrace($e->getTrace(), true)
));
}
}
/**