Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure PHPunit test results output to HTML file?

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

like image 643
Wonky Roger Avatar asked Oct 22 '13 12:10

Wonky Roger


People also ask

What is the PHPUnit XML configuration file used to organize tests?

The <testsuite> Element.

Where do I put PHPUnit test?

You can run all the tests in a directory using the PHPUnit binary installed in your vendor folder. You can also run a single test by providing the path to the test file.

What is code coverage PHPUnit?

In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.

How do I run a single PHPUnit test?

To Run a single PHPUnit Test Case on a method within the file: Open your PHPUnit Test Case file in the editor. Place your cursor on the method you wish to test, right-click and select Run As | PHP Unit Test.


1 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:

  • VisualPHPUnit (resp. at Github)
  • PHPUnit_Html
like image 55
white_gecko Avatar answered Oct 27 '22 03:10

white_gecko