XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      • PHP 5.4 is required to run this test
      • The testing instructions have to be executed in Windows and (Linux or MACOS). For Windows installing "git bash" and one of the latests "XAMPP" versions, which includes PHP 5.4.x, worked well for me. Note that git bash includes PHP 5.3, you might want to use PHP 5.4 (the one included in XAMPP) for behat CLI commands.

      Note that when running in Windows paths should use '\' instead of '/'. Also note that some tests can fail due to unavailable elements (the error would be something like "there is no element with id|label|title 'Username'") further work is being done in MDL-37750 to solve it.

      Installation

      Usage without Javascript tests

      • Follow usage instructions (http://docs.moodle.org/dev/Acceptance_testing#Running_tests)
        • Open a CLI, "cd /to/your/site" and "php -S localhost:8000"
        • Open another CLI, "cd /to/your/site" and "php admin/tool/behat/cli/util.php --enable"
        • The process SHOULD finish well and a new behat.yml SHOULD be created in "$CFG->behat_dataroot/behat/"
      • Check the regular site can be accessed as expected
        • Open a browser and go to your $CFG->wwwroot, you SHOULD see the regular moodle environment with your site fullname on it
        • Open a browser and go to http://localhost:8000, you SHOULD see a single course and the name of the site SHOULD be "Acceptance test site"
        • Check the new behat.yml in "$CFG->behat_dataroot/behat", it SHOULD include a list of files in the features section and a list of steps definitions under steps_definitions
        • This two lists SHOULD NOT contain duplicate elements
        • In "cd /to/your/site" run "vendor/bin/behat --config /path/to/your/CFG_behat_dataroot/behat/behat.yml --tags ~@javascript" to run the tests excluding the ones with Javascript
        • You SHOULD NOT receive any exception and the process SHOULD finish as expected, showing the number of tests "passes" and "fails"
        • Don't close the built-in web server

      Usage with Javascript tests

      • Run all the tests suite
        • Open another CLI and "java -jar /path/to/your/selenium-server-standalone-2.28.0.jar"
        • Run again the tests but now including a test that involves Selenium: "cd /to/your/site" and "vendor/bin/behat --config /path/to/your/CFG_behat_dataroot/behat/behat.yml --tags @blocks"
        • You SHOULD NOT receive any exception and the process SHOULD finish as expected, showing the number of tests passed and failed

      Advanced config params

      • Ensure the alternative $CFG->behat_wwwroot is used
        • Edit your config.php file and add a line with $CFG->behat_wwwroot = 'http://localhost:8005';
        • Stop and restart your PHP built-in web server but now with "php -S localhost:8005"
        • Run "php admin/tool/behat/cli/util.php --enable" again
        • Check the new behat.yml, the file, it SHOULD contain "base_url: 'http://localhost:8005'"
        • Run "vendor/bin/behat --config /path/to/your/CFG_behat_dataroot/behat/behat.yml --tags ~@javascript"
        • You SHOULD NOT receive any exception regarding your server was not initialised and the process SHOULD finish showing the numbers of "passes" and "fails"
      • Ensure the switch completely works as expected
        • Edit your config.php file and add a line with '$CFG->behat_switchcompletely = true;' (don't remove the behat_wwwroot, this setting is supposed to override it)
        • Stop your PHP built-in web server
        • Run "php admin/tool/behat/cli/util.php --enable" again
        • Open a browser and go to your $CFG->wwwroot, you SHOULD see a single course and the name of the site SHOULD be "Acceptance test site"
      Show
      PHP 5.4 is required to run this test The testing instructions have to be executed in Windows and (Linux or MACOS). For Windows installing "git bash" and one of the latests "XAMPP" versions, which includes PHP 5.4.x, worked well for me. Note that git bash includes PHP 5.3, you might want to use PHP 5.4 (the one included in XAMPP) for behat CLI commands. Note that when running in Windows paths should use '\' instead of '/'. Also note that some tests can fail due to unavailable elements (the error would be something like "there is no element with id|label|title 'Username'") further work is being done in MDL-37750 to solve it. Installation Install a fresh new master site with MDL-37046 patches applied or integrated Follow Installation instructions ( http://docs.moodle.org/dev/Acceptance_testing#Installation ) including Selenium, to resume: Download http://selenium.googlecode.com/files/selenium-server-standalone-2.28.0.jar "cd /to/your/site" Add $CFG->behat_prefix (test database prefix) and $CFG->behat_dataroot (behat test dataroot directory) values in config.php curl http://getcomposer.org/installer | php php composer.phar install --dev You SHOULD NOT receive any error (it depends on upstream projects anyway) php admin/tool/behat/cli/util.php --install Check if behat is working correctly with the basic behat.yml.dist configuration "cd /to/your/site" Run "vendor/bin/behat -h" You SHOULD see something like http://docs.behat.org/guides/6.cli.html#command-line-tool-behat Usage without Javascript tests Follow usage instructions ( http://docs.moodle.org/dev/Acceptance_testing#Running_tests ) Open a CLI, "cd /to/your/site" and "php -S localhost:8000" Open another CLI, "cd /to/your/site" and "php admin/tool/behat/cli/util.php --enable" The process SHOULD finish well and a new behat.yml SHOULD be created in "$CFG->behat_dataroot/behat/" Check the regular site can be accessed as expected Open a browser and go to your $CFG->wwwroot, you SHOULD see the regular moodle environment with your site fullname on it Open a browser and go to http://localhost:8000 , you SHOULD see a single course and the name of the site SHOULD be "Acceptance test site" Check the new behat.yml in "$CFG->behat_dataroot/behat", it SHOULD include a list of files in the features section and a list of steps definitions under steps_definitions This two lists SHOULD NOT contain duplicate elements In "cd /to/your/site" run "vendor/bin/behat --config /path/to/your/CFG_behat_dataroot/behat/behat.yml --tags ~@javascript" to run the tests excluding the ones with Javascript You SHOULD NOT receive any exception and the process SHOULD finish as expected, showing the number of tests "passes" and "fails" Don't close the built-in web server Usage with Javascript tests Run all the tests suite Open another CLI and "java -jar /path/to/your/selenium-server-standalone-2.28.0.jar" Run again the tests but now including a test that involves Selenium: "cd /to/your/site" and "vendor/bin/behat --config /path/to/your/CFG_behat_dataroot/behat/behat.yml --tags @blocks" You SHOULD NOT receive any exception and the process SHOULD finish as expected, showing the number of tests passed and failed Advanced config params Ensure the alternative $CFG->behat_wwwroot is used Edit your config.php file and add a line with $CFG->behat_wwwroot = 'http://localhost:8005'; Stop and restart your PHP built-in web server but now with "php -S localhost:8005" Run "php admin/tool/behat/cli/util.php --enable" again Check the new behat.yml, the file, it SHOULD contain "base_url: 'http://localhost:8005'" Run "vendor/bin/behat --config /path/to/your/CFG_behat_dataroot/behat/behat.yml --tags ~@javascript" You SHOULD NOT receive any exception regarding your server was not initialised and the process SHOULD finish showing the numbers of "passes" and "fails" Ensure the switch completely works as expected Edit your config.php file and add a line with '$CFG->behat_switchcompletely = true;' (don't remove the behat_wwwroot, this setting is supposed to override it) Stop your PHP built-in web server Run "php admin/tool/behat/cli/util.php --enable" again Open a browser and go to your $CFG->wwwroot, you SHOULD see a single course and the name of the site SHOULD be "Acceptance test site"
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-37046_master

      Description

      The integration in Moodle requires to:

      1. Run the tests in an alternative environment rather than using the regular database and dataroot
      2. Gather the acceptance tests and steps definitions of all subsystems and plugins and run them through CLI, all together or a subset of them filtering by tag.
      3. List and filter the available steps definitions to write new tests with them

      The 2nd point is developer-oriented and the 3rd point should be user-friendly to be also used by non-technical users

      This issue is the first one of the BDD/acceptance tests issues and is a requirement for others.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/13