Skip to content

HTML report renderer uses code coverage driver #1091

@sebastianbergmann

Description

@sebastianbergmann

Hi 👋🏻

Thanks for the excellent work, however it seems this commit breaks the generation of HTML coverage since the driver is no longer serialized.

First I run phpunit with coverage enabled:

$ vendor/bin/phpunit --coverage-php var/coverage/phpunit/coverage.cov
PHPUnit 12.3.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.4 with PCOV 1.0.12
Configuration: /app/phpunit.xml.dist

.                                                                   1 / 1 (100%)

Faker seed: 885186

Time: 00:00.251, Memory: 79.00 MB

OK (1 test, 11 assertions)

Generating code coverage report in PHP format ... done [00:00]

Then I try to merge the code coverage and get this error:

$ vendor/bin/phpcov merge --html coverage/html/ var/coverage/
phpcov 11.0.1 by Sebastian Bergmann.

Generating code coverage report in HTML format ... 
Fatal error: Uncaught Error: Typed property SebastianBergmann\CodeCoverage\CodeCoverage::$driver must not be accessed before initialization in /app/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:396
Stack trace:
#0 /app/vendor/phpunit/php-code-coverage/src/Report/Html/Facade.php(53): SebastianBergmann\CodeCoverage\CodeCoverage->collectsBranchAndPathCoverage()
#1 /app/vendor/phpunit/phpcov/src/cli/Command.php(113): SebastianBergmann\CodeCoverage\Report\Html\Facade->process(Object(SebastianBergmann\CodeCoverage\CodeCoverage), 'coverage/html/')
#2 /app/vendor/phpunit/phpcov/src/cli/MergeCommand.php(84): SebastianBergmann\PHPCOV\Command->handleReports(Object(SebastianBergmann\CodeCoverage\CodeCoverage), Object(SebastianBergmann\PHPCOV\Arguments))
#3 /app/vendor/phpunit/phpcov/src/cli/Application.php(51): SebastianBergmann\PHPCOV\MergeCommand->run(Object(SebastianBergmann\PHPCOV\Arguments))
#4 /app/vendor/phpunit/phpcov/phpcov(30): SebastianBergmann\PHPCOV\Application->run(Array)
#5 /app/vendor/bin/phpcov(119): include('/app/...')
#6 {main}
  thrown in /app/vendor/phpunit/php-code-coverage/src/CodeCoverage.php on line 396

It seems that it doesn't break merging the code coverage with --cobertura or --text formatters.

Would it be possible to serialize the driver back again?

Originally posted by @J-Ben87 in #1090

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions