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

Behat: add possibility to skip tests according to Moodle version

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
    • MDL-76731_401
    • MDL-76731_master
    • Hide
      1. Open mod/quiz/tests/behat/add_quiz.feature
      2. Add the line Given the site is running Moodle version 5.0 or higher as the first line of the Background section
      3. Run the test and verify the output says: "1 test skipped" (or similar)
      4. Change the newly added line to Given the site is running Moodle version 3.9 or higher
      5. Run the test again and verify it passes.
      6. Remove the newly added line and add Given the site is running Moodle version 3.0 or lower instead
      7. Run the test again and verify the output says: "1 test skipped" (or similar)
      8. Change the newly added line to Given the site is running Moodle version 4.2 or lower
      9. Run the test again and verify it passes.
      10. Remove the newly added line in order to revert the test to its original state.
      Show
      Open mod/quiz/tests/behat/add_quiz.feature Add the line Given the site is running Moodle version 5.0 or higher as the first line of the Background section Run the test and verify the output says: "1 test skipped" (or similar) Change the newly added line to Given the site is running Moodle version 3.9 or higher Run the test again and verify it passes. Remove the newly added line and add Given the site is running Moodle version 3.0 or lower instead Run the test again and verify the output says: "1 test skipped" (or similar) Change the newly added line to Given the site is running Moodle version 4.2 or lower Run the test again and verify it passes. Remove the newly added line in order to revert the test to its original state.

      In some cases, acceptance tests must be written in a different way for older and newer versions of Moodle. I suggest adding two new steps to make sure the behat site is running at least / at most a certain Moodle version. If this requirement is not met, the test will be skipped instead of failing.

      The suggested patch is heavily based on a suggestion from dobedobedoh. Thanks!

            philippimhof Philipp Imhof
            philippimhof Philipp Imhof
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Ilya Tregubov Ilya Tregubov
            Kim Jared Lucas Kim Jared Lucas
            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, 9 minutes
                2h 9m

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