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

Behat framework: add skip support

    XMLWordPrintable

Details

    • MOODLE_27_STABLE
    • MOODLE_27_STABLE
    • MDL-43330_master
    • 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.
    • 8
    • 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

              jerome Jérôme Mouneyrac
              jerome Jérôme Mouneyrac
              David Monllaó David Monllaó
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Ankit Agarwal Ankit Agarwal
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

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