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

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

XMLWordPrintable

    • MOODLE_25_STABLE
    • MOODLE_25_STABLE
    • MDL-38041_master
    • 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

      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.

            dmonllao David Monllaó
            dmonllao David Monllaó
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

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