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

Create behat repeated generator.

XMLWordPrintable

    • MOODLE_400_STABLE
    • MDL-70022-master_behat_repeated_generator
    • Hide

      Set up behat environment (Docker example)

      1. Build test containers using the moodle hq docker repo:

      git pull git@github.com:moodlehq/moodle-docker.git
      cd moodle-docker

      2. Create the environment variables based on the location of it's files and DB type:

      export MOODLE_DOCKER_WWWROOT=/path/to/moodle/code
      export MOODLE_DOCKER_DB=pgsql

      3. Override your moodle config file with the moodle-docker config (I save a backup first):

      cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php

      4. Start up the containers and wait for DB connection:

      bin/moodle-docker-compose up -d
      bin/moodle-docker-wait-for-db

      5. Initialise the behat test environment:

      bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php

      Run new behat tests with new generator.

       1. Run

      bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/run.php /var/www/html/lib/tests/behat/repeatinggenerator.feature

      2. You should see all steps pass.

       

       

      Show
      Set up behat environment (Docker example) 1. Build test containers using the moodle hq docker repo: git pull git@github.com:moodlehq/moodle-docker.git cd moodle-docker 2. Create the environment variables based on the location of it's files and DB type: export MOODLE_DOCKER_WWWROOT=/path/to/moodle/code export MOODLE_DOCKER_DB=pgsql 3. Override your moodle config file with the moodle-docker config (I save a backup first): cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php 4. Start up the containers and wait for DB connection: bin/moodle-docker-compose up -d bin/moodle-docker-wait-for-db 5. Initialise the behat test environment: bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php Run new behat tests with new generator.  1. Run bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/run.php /var/www/html/lib/tests/behat/repeatinggenerator.feature 2. You should see all steps pass.    

      Problem: A test requires bulk mock data to make sense. E.g. Testing pagination.

      Current solution: Use a generator for the data, and insert every instance in the feature file.

      https://github.com/moodle/moodle/blob/master/course/tests/behat/course_category_management_listing.feature#L528

      Proposed solution: Create a 'repeated generator' that can iteratively generate bulk data based on a generator and a count.

      And I create [count] [generator] with data:
          | category  | CAT1           |
          | fullname  | Course [count] |
          | shortname | course[count   |
          | idnumber  | C[count]       |

      Andrew Nicol's implementation: https://github.com/andrewnicols/moodle/commit/repeatedgenerator

            andrewmadden Andrew Madden
            andrewmadden Andrew Madden
            Dmitrii Metelkin Dmitrii Metelkin
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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