Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48613

Allow behat to use generator after interacting with website OR prevent

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_28_STABLE
    • Sprint:
      Team A Sprint 1, Team '; drop tables Sprint 2
    • Issue size:
      Medium

      Description

      When you run the course/tests/behat/activities_edit_completion.feature added in MDL-48452, on the first time after installing Behat tables, it fails and causes a warning. All future runs, including after running Behat init when it doesn't reinstall tables, work correctly.

      This applies on master and 2.8 (and probably 2.7 but I didn't test there).

      The steps involved are:

          Given I log in as "admin"
          And I set the following administration settings values:
            | Enable completion tracking | 1 |
          And I log out
          And the following "courses" exist:
            | fullname | shortname | enablecompletion |
            | Course 1 | C1        | 1                |
      

      Results on my system are (the first one is after reinstalling Behat tables, second is immediately after):

      $  vendor/bin/behat --config C:/Users/sm449/AppData/Local/Temp/tempmoodledata_behat/behat/behat.yml
       --name="Pressing the unlock button allows the user to edit completion settings"
      Moodle 2.8.1+ (Build: 20141205), pgsql, 78d8dc13c80a8f70058c2d0f005d2dff065298f3
      Server OS "WINNT", Browser: "firefox"
      Started at 16-12-2014, 17:35
      ........++ Did you forget to set $CFG->enablecompletion before generating module with completion tracking? ++
      * line 255 of \lib\testing\generator\module_generator.php: call to debugging()
      * line 61 of \mod\page\tests\generator\lib.php: call to testing_module_generator->create_instance()
      * line 466 of \lib\testing\generator\data_generator.php: call to mod_page_generator->create_instance()
      * line 314 of \lib\tests\behat\behat_data_generators.php: call to testing_data_generator->create_module()
      * line 226 of \lib\tests\behat\behat_data_generators.php: call to behat_data_generators->process_activity()
      * line ? of unknownfile: call to behat_data_generators->the_following_exist()
      * line 155 of \vendor\behat\behat\src\Behat\Behat\Definition\Annotation\Definition.php: call to call_user_func_array()
      * line 228 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleStepTester.php: call to Behat\Behat\Definition\Annotation\Definition->run()
      * line 126 of \vendor\behat\behat\src\Behat\Behat\Tester\StepTester.php: call to Moodle\BehatExtension\Tester\MoodleStepTester->executeStepDefinition()
      * line 172 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleStepTester.php: call to Behat\Behat\Tester\StepTester->executeStep()
      * line 148 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleStepTester.php: call to Moodle\BehatExtension\Tester\MoodleStepTester->executeStep()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Moodle\BehatExtension\Tester\MoodleStepTester->visit()
      * line 97 of \vendor\behat\behat\src\Behat\Behat\Tester\BackgroundTester.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Behat\Behat\Tester\BackgroundTester->visit()
      * line 98 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleScenarioTester.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 78 of \vendor\behat\behat\src\Behat\Behat\Tester\ScenarioTester.php: call to Moodle\BehatExtension\Tester\MoodleScenarioTester->visitBackground()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Behat\Behat\Tester\ScenarioTester->visit()
      * line 88 of \vendor\behat\behat\src\Behat\Behat\Tester\FeatureTester.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Behat\Behat\Tester\FeatureTester->visit()
      * line 150 of \vendor\behat\behat\src\Behat\Behat\Console\Command\BehatCommand.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 128 of \vendor\behat\behat\src\Behat\Behat\Console\Command\BehatCommand.php: call to Behat\Behat\Console\Command\BehatCommand->runFeatures()
      * line 241 of \vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php: call to Behat\Behat\Console\Command\BehatCommand->execute()
      * line 895 of \vendor\symfony\symfony\src\Symfony\Component\Console\Application.php: call to Symfony\Component\Console\Command\Command->run()
      * line 191 of \vendor\symfony\symfony\src\Symfony\Component\Console\Application.php: call to Symfony\Component\Console\Application->doRunCommand()
      * line 68 of \vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php: call to Symfony\Component\Console\Application->doRun()
      * line 121 of \vendor\symfony\symfony\src\Symfony\Component\Console\Application.php: call to Behat\Behat\Console\BehatApplication->doRun()
      * line 32 of \vendor\behat\behat\bin\behat: call to Symfony\Component\Console\Application->run()
      .........F------
       
      (::) failed steps (::)
       
      01. Button matching locator "'Unlock completion options'" not found.
          In step `And I press "Unlock completion options"'.                                      # behat_forms::press_button()
          From scenario `Pressing the unlock button allows the user to edit completion settings'. # C:\Users\sm449\workspace\core-moodle-github\course\tests\behat\activities_edit_completion.feature:35
          Of feature `Edit completion settings of an activity'.                                   # C:\Users\sm449\workspace\core-moodle-github\course\tests\behat\activities_edit_completion.feature
       
      1 scenario (1 failed)
      24 steps (17 passed, 6 skipped, 1 failed)
      0m35.26s
       
      $  vendor/bin/behat --config C:/Users/sm449/AppData/Local/Temp/tempmoodledata_behat/behat/behat.yml
       --name="Pressing the unlock button allows the user to edit completion settings"
      Moodle 2.8.1+ (Build: 20141205), pgsql, 78d8dc13c80a8f70058c2d0f005d2dff065298f3
      Server OS "WINNT", Browser: "firefox"
      Started at 16-12-2014, 17:36
      ........................
       
      1 scenario (1 passed)
      24 steps (24 passed)
      0m34.256s
      

      What is happening is that the generator thinks that completion is not enabled and causes a warning. However the enablecompletion admin setting was turned on in 2 test steps ago, so this should work (as it does in second and future runs).

      Note that rerunning init.php will not make it fail again. To make it fail again, you have to run behat/cli/util.php --drop, then behat/cli/init.php, and then rerun the test.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              quen Sam Marshall
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: