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

Behat does not reset unknown config variables between scenarios

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Copy the attached mdl66836.patch file to the Moodle root.
      2. Apply the previous patch using the following git command (this should add a new feature file, and a new (temporary) Behat step to an existing step library): 

        git apply mdl66836.patch

      3. Initialise behat
      4. Run a Behat test using the tag @silly
      5. Verify the test passes 
         

        Started at 09-10-2019, 19:46
        ...
        2 scenarios (2 passed)
        3 steps (3 passed)
        0m4.72s (45.89Mb)
        

         

       
       

      Show
      Copy the attached mdl66836.patch file to the Moodle root. Apply the previous patch using the following git command (this should add a new feature file, and a new (temporary) Behat step to an existing step library):  git apply mdl66836.patch Initialise behat Run a Behat test using the tag @silly Verify the test passes    Started at 09 - 10 - 2019 , 19 : 46 ... 2 scenarios ( 2 passed) 3 steps ( 3 passed) 0m4.72s ( 45 .89Mb)      
    • Affected Branches:
      MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull 3.7 Branch:
      MDL-66836-m37
    • Pull Master Branch:
      MDL-66836-master

      Description

      Behat resets config variables between scenarios, but only if they are the predefined ones that were set up during the Moodle installation for behat init (i.e. they are listed in a settings.php file).

      If you have config variables that are set up ad-hoc, for example to be used in indicating some behaviour for Behat mocking, or something that (for real use outside Behat) can be set up only in config.php, then these are not reset.

      Example (this requires a new step definition, I'll include a patch):

        Scenario: Set a silly admin setting and a real one
          Given the following config values are set as admin:
            | config         | value |
            | sillyvariable  | 666   |
            | enableoutcomes | 1     |
       
        Scenario: Check both admin settings
          Then config value "enableoutcomes" should be "0" # passes
          And config value "sillyvariable" should be "" # fails, value is actually 666
      

      If you run the second scenario on its own, the test passes. If you run both scenarios, the test fails at the indicated line.

        Attachments

          Activity

            People

            Assignee:
            quen Sam Marshall
            Reporter:
            quen Sam Marshall
            Peer reviewer:
            Eloy Lafuente (stronk7)
            Integrator:
            Sara Arjona (@sarjona)
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Nov/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 11 minutes
                2h 11m