HTML reports and Behat 3.0

HTML reports and Behat 3.0

by Rex Lorenzo -
Number of replies: 2

Before in Moodle 2.7 and Behat 2 I was able to pass in the parameter to get a nice HTML report that outlined the failed tests and also gave the number of passed/failed tests.

How can I get the same/similar report in Behat 3 and Moodle 3.1? In the docs it says:

html and failed outputs are not maintained by behat. We are planning to include BehatHTMLFormatter plugin maintained by Neal Vanmeert and write our custom failed formatter. 

What parameters do I pass? The old parameters doesn't do anything. Also, has anyone been able to get junit reporting to work as well?

Average of ratings: -
In reply to Rex Lorenzo

Re: HTML reports and Behat 3.0

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I've managed to get the junit reporting (--format=junit --out=/path/to/output/folder). However, unlike behat 2 where you got a separate XML file for each feature, you now get a single XML file with all the features.  This means that if you use --rerun to re-run failed tests, you'll get a new XML file with just the features from the second run, it won't just overwrite the XML for the re-run tests as before.  I've had to write some code to read the XML from the re-run and overwrite the corresponding feature/scenario in the original output.

In reply to Rex Lorenzo

Re: HTML reports and Behat 3.0

by Rajesh Taneja -

Hello Rex,


We didn't end up adding BehatHTMLFormatter plugin as part of upgrade to Behat 3 as it's a third party plugin. You can do following to use it on your test server.

  1. Add following to your config.php
    $CFG->behat_config = array(
    'default' => array(
    'formatters' => array(
    'html' => array(
    'output_path' => '/home/rajesh/Desktop'
    )
    ),
    'extensions' => array(
    'emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension' => array(
    'name' => 'html',
    'renderer' => 'Twig,Behat2',
    'file_name' => 'index',
    'print_args' => true,
    'print_outp' => true,
    'loop_break' => true
    )
    )

    )
    );
  2. Initialize behat (php admin/tool/behat/cli/init.php) 
  3. run "php composer.phar require --dev emuse/behat-html-formatter"


As per failed steps, it seems it will be helpful formatter, feel free to create an issue and I will be happy to add that as part of moodle-behat-extension