From 96006f2d7a4ac16ef64b0fc581f1222bd5c2e18b Mon Sep 17 00:00:00 2001 From: Nicolae Iotu Date: Wed, 29 Nov 2023 01:23:13 +0000 Subject: [PATCH] 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. --- phpunit.xml.dist | 2 ++ tests/README.md | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8735975fa7..e23d8ad9d6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -35,6 +35,8 @@ + + diff --git a/tests/README.md b/tests/README.md index 52ddc1e671..9f9b0e471c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -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