Skip to content

Commit 437314c

Browse files
authored
Merge pull request #8269 from NicolaeIotu/phpunit-default-html-text-coverage
add: generate also html coverage reports when running script 'test'
2 parents 8584f1b + d1b4c87 commit 437314c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,23 @@ 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
117-
./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
122+
./phpunit --colors --coverage-text=build/coverage/text/coverage.txt --coverage-html=build/coverage/html/ -d memory_limit=1024m
118123
```
119124

120125
This runs all of the tests again collecting information about how many lines,
121126
functions, and files are tested. It also reports the percentage of the code that is covered by tests.
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.
127130

128131
## PHPUnit XML Configuration
129132

0 commit comments

Comments
 (0)