database icon indicating copy to clipboard operation
database copied to clipboard

Feat: Adds the start of code coverage.

Open wess opened this issue 4 years ago • 2 comments

Beginnings of adding code coverage to projects using PHPUnit. This uses PCOV as the driver and updates the phpunit.xml to include filters for coverage.

required PCOV: $ pecl install pcov

Then run: $ phpunit --coverage-text=tests/coverage/report.txt

Adapters, in tests, are updated to allow for environment variables for connections, as well as the original as fallback.

wess avatar Nov 23 '21 16:11 wess

Is there a reason we are using a dependency for generating a coverage report ? How would it be different from simply using the coverage report that phpunit provides out of the box ?

IMO it would be much cleaner to use vendor/bin/phpunit --coverage-clover coverage.xml and use the Codecov service that will take care of generating dynamic code coverage README badges and even provides some other features.

cc: @eldadfux

Not sure I understand? That is the Code coverage that PHP offers out of the box 😄

You need some kind of driver that can actually check what code is covered or not => https://phpunit.readthedocs.io/en/9.5/code-coverage-analysis.html

Even the official code cov example does not work because there is no driver for this installed:

Bildschirmfoto 2021-12-10 um 12 10 28

Why their example works?

Travis is using XDebug by default in their PHP envs, we are running in Docker - so we have to install something anyway 👍🏻

TorstenDittmann avatar Dec 10 '21 11:12 TorstenDittmann

I think the dependency should be fine and as far as I can recall is required.

eldadfux avatar Dec 22 '21 04:12 eldadfux