Skip to content

Commit 96006f2

Browse files
committed
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.
1 parent 9e8786c commit 96006f2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
<report>
3737
<clover outputFile="build/logs/clover.xml"/>
38+
<html outputDirectory="build/coverage/html" highLowerBound="80"/>
39+
<text outputFile="build/coverage/text/coverage.txt"/>
3840
</report>
3941
</coverage>
4042

tests/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,13 @@ You can run the tests without running the live database and the live cache tests
110110

111111
## Generating Code Coverage
112112

113-
To generate coverage information, including HTML reports you can view in your browser,
114-
you can use the following command:
113+
The coverage reports are generated by default after the execution of tests. These reports
114+
include a textual overview and HTML reports which can be opened in a browser.
115+
116+
The text file can be found at **build/coverage/text/coverage.txt**.
117+
The HTML files can be viewed by opening **build/coverage/html/index.html** in your favorite browser.
118+
119+
Alternatively you can use the following command:
115120

116121
```console
117122
./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
122127
It is collected in two formats: a simple text file that provides an overview as well
123128
as a comprehensive collection of HTML files that show the status of every line of code in the project.
124129

125-
The text file can be found at **tests/coverage.txt**.
126-
The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser.
130+
For the example above, the text file can be found at **tests/coverage.txt** and
131+
the HTML files can be viewed by opening **tests/coverage/index.html**.
127132

128133
## PHPUnit XML Configuration
129134

0 commit comments

Comments
 (0)