mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-46891 behat: If setup problem then stop execution
Exception are handled via CallCenter and execution is not stopped if execption is thrown in beforescenario. If any setup problem encountered, then stop execution.
This commit is contained in:
parent
07298309dc
commit
0f3fba7d66
1 changed files with 9 additions and 10 deletions
|
@ -246,15 +246,14 @@ class behat_hooks extends behat_base {
|
|||
} catch (CurlExec $e) {
|
||||
// Exception thrown by WebDriver, so only @javascript tests will be caugth; in
|
||||
// behat_util::is_server_running() we already checked that the server is running.
|
||||
throw new Exception($driverexceptionmsg);
|
||||
$this->stop_execution($driverexceptionmsg);
|
||||
} catch (DriverException $e) {
|
||||
throw new Exception($driverexceptionmsg);
|
||||
$this->stop_execution($driverexceptionmsg);
|
||||
} catch (UnknownError $e) {
|
||||
// Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions.
|
||||
$this->throw_unknown_exception($e);
|
||||
$this->stop_execution($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
// We need the Mink session to do it and we do it only before the first scenario.
|
||||
if (self::is_first_scenario()) {
|
||||
behat_selectors::register_moodle_selectors($session);
|
||||
|
@ -287,7 +286,7 @@ class behat_hooks extends behat_base {
|
|||
// Let's be conservative as we never know when new upstream issues will affect us.
|
||||
$session->visit($this->locate_path('/'));
|
||||
} catch (UnknownError $e) {
|
||||
$this->throw_unknown_exception($e);
|
||||
$this->stop_execution($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -607,15 +606,15 @@ class behat_hooks extends behat_base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Throws an exception after appending an extra info text.
|
||||
* Stops execution because of some exception.
|
||||
*
|
||||
* @throws Exception
|
||||
* @param UnknownError $exception
|
||||
* @param string $exception
|
||||
* @return void
|
||||
*/
|
||||
protected function throw_unknown_exception(UnknownError $exception) {
|
||||
protected function stop_execution($exception) {
|
||||
$text = get_string('unknownexceptioninfo', 'tool_behat');
|
||||
throw new Exception($text . PHP_EOL . $exception->getMessage());
|
||||
echo $text . PHP_EOL . $exception . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue