Home » Php » php – How to configure PHPunit test results output to HTML file?

php – How to configure PHPunit test results output to HTML file?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I’m using phpunit for testing and I really need html reports in HTML format.
Please show me the simplest way or code example.

How to&Answers:

Build in phpunit you can generate a report in HTML using the --testdox-html <output file> option. The output is very rudimentary.

Alternatively you can generate the junit xml output using the --log-junit <output file> option and transform the xml output to html with an xsl-script, e.g. the one from phing (you will need phpunit-noframes.xsl and str.replace.function.xsl) using an xsltprocessor like xsltproc. This will give a little bit more information.

For the ultimate power there are frontends for phpunit which displays the test results in the browser as HTML, this could be worth a look as well: