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

Behat does not reset unknown config variables between scenarios

XMLWordPrintable

    • MOODLE_37_STABLE
    • MOODLE_36_STABLE, MOODLE_37_STABLE
    • MDL-66836-master
    • 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)      

      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.

            quen Sam Marshall
            quen Sam Marshall
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.