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

Fail behat tests when exceptions or debugging() messages are thrown

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Delete $CFG->dirroot/composer.lock and $CFG->dirroot/vendor
      2. Edit composer.json and change

         - "moodlehq/behat-extension": "1.0.*"
         + "moodlehq/behat-extension": "dev-master"
        

      3. Update your behat test environment and run behat with --tags @core_group option
      4. The test SHOULD pass
      5. Edit group/autogroup.php and add a throw new coding_exception('asdasdasd'); after $editform->display();
      6. Run behat with --tags @core_group option
      7. You SHOULD see a failure with a message containing Moodle exception:
      8. Edit group/autogroup.php and replace the exception with a echo $imavarandidontexist;
      9. Run behat with --tags @core_group option
      10. You SHOULD see a failure with a message containing PHP debug message/s found:
      11. Edit group/autogroup.php and replace the echo for this, copy & paste to keep the line break: echo 'line 112 of asd/asdasdasd/asd/a/sdasd: call to asdfFFF->Fasdf() line 112 of asd/asdasdasd/asd/a/sdasd: call to asd_fFFF->Fasdf()
        line 112 of asd/asdasdasd/asd/a/sdasd: call to asdfFFF::Fasdf()';
      12. Run behat with -tags @core_group option# Run behat with -tags @core_group option
      13. You SHOULD see a failure with a message containing Other backtraces found
      14. Edit group/autogroup.php and replace the echo for a debugging('asd');
      15. Run behat with -tags @core_group option# Run behat with -tags @core_group option
      16. You SHOULD see a failure with a message containing Debugging message/s found
      1. Edit group/autogroup.php and replace the debugging() message (if is still present) for echo $imavarandidontexist;
      2. Reload page and inspect the source code of the notice
      3. It SHOULD NOT be wrapped in a <div class="phpdebugmessage"> container
      Show
      Delete $CFG->dirroot/composer.lock and $CFG->dirroot/vendor Edit composer.json and change - "moodlehq/behat-extension": "1.0.*" + "moodlehq/behat-extension": "dev-master" Update your behat test environment and run behat with --tags @core_group option The test SHOULD pass Edit group/autogroup.php and add a throw new coding_exception('asdasdasd'); after $editform->display(); Run behat with --tags @core_group option You SHOULD see a failure with a message containing Moodle exception: Edit group/autogroup.php and replace the exception with a echo $imavarandidontexist; Run behat with --tags @core_group option You SHOULD see a failure with a message containing PHP debug message/s found: Edit group/autogroup.php and replace the echo for this, copy & paste to keep the line break: echo 'line 112 of asd/asdasdasd/asd/a/sdasd: call to asdfFFF->Fasdf() line 112 of asd/asdasdasd/asd/a/sdasd: call to asd_fFFF->Fasdf() line 112 of asd/asdasdasd/asd/a/sdasd: call to asdfFFF::Fasdf()'; Run behat with - tags @core_group option# Run behat with -tags @core_group option You SHOULD see a failure with a message containing Other backtraces found Edit group/autogroup.php and replace the echo for a debugging('asd'); Run behat with - tags @core_group option# Run behat with -tags @core_group option You SHOULD see a failure with a message containing Debugging message/s found Edit group/autogroup.php and replace the debugging() message (if is still present) for echo $imavarandidontexist; Reload page and inspect the source code of the notice It SHOULD NOT be wrapped in a <div class="phpdebugmessage"> container
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-38041_master

      Description

      Behat allows us to specify which levels of PHP errors, when thrown, will fail a test, but this does not allow for debugging() messages as they are Moodle specific.

      As discused with Dan, functional tests should fail if a debugging message or exceptions are thrown.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dmonllao David Monllaó
              Reporter:
              dmonllao David Monllaó
              Integrator:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Tester:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

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