From ab1c2037fc6fc9ad4f6f52563c151d5b6f7a941d Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 17 Jan 2017 10:28:35 +0800 Subject: [PATCH] MDL-57669 behat: Exit with error code if step undefined --- lib/tests/behat/behat_hooks.php | 5 +++++ mod/quiz/tests/behat/editing_section_headings.feature | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 33585c4667a83..7d61c481166ef 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -386,6 +386,11 @@ public function before_step_javascript(BeforeStepScope $scope) { 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) { diff --git a/mod/quiz/tests/behat/editing_section_headings.feature b/mod/quiz/tests/behat/editing_section_headings.feature index ba3bbcc2abcf4..8b002f295fe71 100644 --- a/mod/quiz/tests/behat/editing_section_headings.feature +++ b/mod/quiz/tests/behat/editing_section_headings.feature @@ -423,5 +423,5 @@ Feature: Edit quiz page - section headings And I click on "Edit quiz" "link" in the "Administration" "block" And I click on the "Remove" page break icon after question "TF10" And I open the "Page 10" add to quiz menu - And I choose "a new section heading" in the open action menu + And I follow "a new section heading" in the open menu Then "TF10" "list_item" should exist in the "Section heading ..." "list_item"