dutchiexl / BehatHtmlFormatterPlugin

This is a behat plugin to generate HTML reports
MIT License
112 stars 116 forks source link

No report generated on 0.2 with PHP 7.4 #118

Open ptmkenny opened 4 years ago

ptmkenny commented 4 years ago

I tried to install this via composer using the instructions in the README, but it isn't working.

composer.json

    "require-dev": {
        "emuse/behat-html-formatter": "^0.2",

behat.yml

default:
  suites:
    default:
      contexts:
        - emuse\BehatHTMLFormatter\Context\ScreenshotContext:
            screenshotDir: /app/tests/screenshots
      formatters:
        html:
          # Where to put the HTML report
          output_path: "%paths.base%"
  extensions:
    emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
      name: html
      renderer: Twig,Behat2,Minimal
      # file_name: index
      print_args: true
      print_outp: true
      loop_break: true

behat command

/app/vendor/bin/behat /app/tests/behat/features/ -c /app/tests/behat/behat-lando.yml --tags '@testme' --clear-screenshots

Result:

Screenshots are generated properly, both by this extension and by Behat Fail Aid. But, no report is generated. I don't see an error in my test output, but there is no report, either.

So I tried adding a report option on the command line like this:

/app/vendor/bin/behat /app/tests/behat/features/ -c /app/tests/behat/behat-lando-selenium.yml --tags '@testme' --clear-screenshots --format html

This gives me the following error:

PHP Warning:  file_put_contents(/Minimal_20200902081512.html): failed to open stream: Permission denied in /app/vendor/emuse/behat-html-formatter/src/Printer/FileOutputPrinter.php on line 174
PHP Stack trace:
PHP   1. {main}() /app/vendor/behat/behat/bin/behat:0
PHP   2. Behat\Testwork\Cli\Application->run() /app/vendor/behat/behat/bin/behat:34
PHP   3. Behat\Testwork\Cli\Application->doRun() /app/vendor/symfony/console/Application.php:148
PHP   4. Behat\Testwork\Cli\Application->doRun() /app/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:124
PHP   5. Behat\Testwork\Cli\Application->doRunCommand() /app/vendor/symfony/console/Application.php:255
PHP   6. Behat\Testwork\Cli\Command->run() /app/vendor/symfony/console/Application.php:987
PHP   7. Behat\Testwork\Cli\Command->execute() /app/vendor/symfony/console/Command/Command.php:255
PHP   8. Behat\Testwork\Tester\Cli\ExerciseController->execute() /app/vendor/behat/behat/src/Behat/Testwork/Cli/Command.php:63
PHP   9. Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications() /app/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:108
PHP  10. Behat\Testwork\Ordering\OrderedExercise->tearDown() /app/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:150
PHP  11. Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->tearDown() /app/vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php:94
PHP  12. Behat\Testwork\EventDispatcher\TestworkEventDispatcherSymfonyLegacy->dispatch() /app/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php:104
PHP  13. Behat\Testwork\EventDispatcher\TestworkEventDispatcherSymfonyLegacy->doDispatch() /app/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/TestworkEventDispatcherSymfonyLegacy.php:36
PHP  14. emuse\BehatHTMLFormatter\Formatter\BehatHTMLFormatter->onAfterExercise() /app/vendor/symfony/event-dispatcher/EventDispatcher.php:214
PHP  15. emuse\BehatHTMLFormatter\Printer\FileOutputPrinter->writeln() /app/vendor/emuse/behat-html-formatter/src/Formatter/BehatHTMLFormatter.php:418
PHP  16. file_put_contents() /app/vendor/emuse/behat-html-formatter/src/Printer/FileOutputPrinter.php:174

Warning: file_put_contents(/Minimal_20200902081512.html): failed to open stream: Permission denied in /app/vendor/emuse/behat-html-formatter/src/Printer/FileOutputPrinter.php on line 174

Call Stack:
    0.0005     450248   1. {main}() /app/vendor/behat/behat/bin/behat:0
    0.0386    6005624   2. Behat\Testwork\Cli\Application->run() /app/vendor/behat/behat/bin/behat:34
    0.0445    6491600   3. Behat\Testwork\Cli\Application->doRun() /app/vendor/symfony/console/Application.php:148
    0.3564   16733896   4. Behat\Testwork\Cli\Application->doRun() /app/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:124
    0.3568   16739776   5. Behat\Testwork\Cli\Application->doRunCommand() /app/vendor/symfony/console/Application.php:255
    0.3568   16739776   6. Behat\Testwork\Cli\Command->run() /app/vendor/symfony/console/Application.php:987
    0.3571   16744712   7. Behat\Testwork\Cli\Command->execute() /app/vendor/symfony/console/Command/Command.php:255
    0.3588   16939320   8. Behat\Testwork\Tester\Cli\ExerciseController->execute() /app/vendor/behat/behat/src/Behat/Testwork/Cli/Command.php:63
    0.3597   17050776   9. Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications() /app/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:108
    5.7644   19318480  10. Behat\Testwork\Ordering\OrderedExercise->tearDown() /app/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:150
    5.7644   19318480  11. Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->tearDown() /app/vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php:94
    5.7648   19326672  12. Behat\Testwork\EventDispatcher\TestworkEventDispatcherSymfonyLegacy->dispatch() /app/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php:104
    5.7648   19327776  13. Behat\Testwork\EventDispatcher\TestworkEventDispatcherSymfonyLegacy->doDispatch() /app/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/TestworkEventDispatcherSymfonyLegacy.php:36
    5.7649   19327776  14. emuse\BehatHTMLFormatter\Formatter\BehatHTMLFormatter->onAfterExercise() /app/vendor/symfony/event-dispatcher/EventDispatcher.php:214
    5.8409   22001048  15. emuse\BehatHTMLFormatter\Printer\FileOutputPrinter->writeln() /app/vendor/emuse/behat-html-formatter/src/Formatter/BehatHTMLFormatter.php:418
    5.8419   22001104  16. file_put_contents() /app/vendor/emuse/behat-html-formatter/src/Printer/FileOutputPrinter.php:174

So I changed the output_path to my screenshots directory, but I am still getting the error when I try to output the report. This is strange to me because the screenshots are output correctly to the same directory, but the report has this permissions error.

How do I generate the report?

ptmkenny commented 4 years ago

Ah, I see. I had to specify --format html --out MYDIRECTORY in the command like this:

behat /app/tests/behat/features/ -c /app/tests/behat/behat-lando-selenium.yml --tags '@testme' --format html --out /app/tests/reports`

I humbly request that you update the documentation with a new section called "behat command" so that people can more easily understand what they need to do to get this working.