Generate also the html coverage reports when running script 'test'

When running 'composer test', if XDebug is installed and setup (xdebug.mode = coverage), in addition to the file build/logs/clover.xml, generate also nice html coverage reports in folder build/coverage.

PHPunit runs normally if XDebug is missing or it is not set for coverage.

View the coverage report at build/coverage/html/index.html.
This commit is contained in:
Nicolae Iotu 2023-11-29 01:23:13 +00:00
parent 9e8786cd09
commit 96006f2d7a
No known key found for this signature in database
GPG Key ID: 81219512687EAC4E
2 changed files with 11 additions and 4 deletions

View File

@ -35,6 +35,8 @@
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage/html" highLowerBound="80"/>
<text outputFile="build/coverage/text/coverage.txt"/>
</report>
</coverage>

View File

@ -110,8 +110,13 @@ You can run the tests without running the live database and the live cache tests
## Generating Code Coverage
To generate coverage information, including HTML reports you can view in your browser,
you can use the following command:
The coverage reports are generated by default after the execution of tests. These reports
include a textual overview and HTML reports which can be opened in a browser.
The text file can be found at **build/coverage/text/coverage.txt**.
The HTML files can be viewed by opening **build/coverage/html/index.html** in your favorite browser.
Alternatively you can use the following command:
```console
./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
@ -122,8 +127,8 @@ functions, and files are tested. It also reports the percentage of the code that
It is collected in two formats: a simple text file that provides an overview as well
as a comprehensive collection of HTML files that show the status of every line of code in the project.
The text file can be found at **tests/coverage.txt**.
The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser.
For the example above, the text file can be found at **tests/coverage.txt** and
the HTML files can be viewed by opening **tests/coverage/index.html**.
## PHPUnit XML Configuration