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

Behat framework: add skip support

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      To test:

      • create a behat scenario
      • create a new behat step (Given I run a skip test)
      • in this test just throw a new Moodle\BehatExtension\Exception\SkippedException
      • call this step as first step and run behat.
        => this step and all following step are narked as skipped.
      • in command line run just after the behat test: echo $?
        => it displays the exit code. The exit code should be 0
      • go to Behat dev docs and add a little comment about how to skip a step.
      Show
      To test: create a behat scenario create a new behat step (Given I run a skip test) in this test just throw a new Moodle\BehatExtension\Exception\SkippedException call this step as first step and run behat. => this step and all following step are narked as skipped. in command line run just after the behat test: echo $? => it displays the exit code. The exit code should be 0 go to Behat dev docs and add a little comment about how to skip a step.
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-43330_master
    • Story Points:
      8
    • Sprint:
      FRONTEND Sprint 7

      Description

      We should be able to skip a behat test. The idea is:

      • the step throw a SkipException
      • MoodleStepTester::executesteps() detect it and return the step as mark been skipped
      • the behat framework automatically skip other steps of the scenario (in theory)

      Example of behat step that do a skip:

      <?php
       
      /**
       * Behat editpdf-related steps definitions.
       *
       * @package    assignfeedback_editpdf
       * @category   test
       * @copyright  2013 Jerome Mouneyrac
       * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
       */
       
      // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
       
      require_once(__DIR__ . '/../../../../../../lib/behat/behat_base.php');
       
      use Behat\Behat\Context\Step\Given as Given;
       
      /**
       * Steps definitions related with the editpdf.
       *
       * @package    assignfeedback_editpdf
       * @category   test
       * @copyright  2013 Jerome Mouneyrac
       * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
       */
      class behat_assignfeedback_editpdf extends behat_base {
       
          /**
           * Checks that Ghostscript is installed.
           *
           * @Given /^ghostscript is installed$/
           */
          public function ghostscriptIsInstalled() {
              
                  throw new \Moodle\BehatExtension\Exception\SkippedException;
       
          }
      }
      
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

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