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

Use Behat alternative login

XMLWordPrintable

      Throughout Moodle, in Behat tests, we are testing the same things over and over again unnecessarily.
      The main offender being "I log in as"
      Often I see:

      Given I log in as "someuser"

      "I log in as" is not a given and it is not a performant way to log a user into moodle as part of a behat test.

      A performant step would instead be:

      Given I am logged in as "someuser"

      Which places the user in the required state without user interaction

      Unless there is some reason for actually needing to test a user filling in the log in form and then submitting the form there is absolutely no need for that to happen in a test.
      In fact, there should probably be just 1 test in the entirety of Moodle where "I log in as" is used and that test should be specifically to test the log in feature.

      This article goes into more detail about the problems of not using "Given" steps correctly.

      https://brudinie.medium.com/behat-given-for-the-win-62f24a098888

            dobedobedoh Andrew Lyons
            brudinie guy thomas
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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