From ada21cb0c836110f335ce3e3034038881091e985 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 17 Jan 2017 10:30:45 +0800 Subject: [PATCH] MDL-57669 behat: Exit with error code if step undefined --- lib/tests/behat/behat_hooks.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 239dd99d489..d5254b1b5dc 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -429,6 +429,11 @@ class behat_hooks extends behat_base { public function after_step_javascript(AfterStepScope $scope) { global $CFG, $DB; + // If step is undefined then throw exception, to get failed exit code. + if ($scope->getTestResult()->getResultCode() === Behat\Behat\Tester\Result\StepResult::UNDEFINED) { + throw new coding_exception("Step '" . $scope->getStep()->getText() . "'' is undefined."); + } + // Save the page content if the step failed. if (!empty($CFG->behat_faildump_path) && $scope->getTestResult()->getResultCode() === Behat\Testwork\Tester\Result\TestResult::FAILED) {