-
-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Coverage uses PHPUnit but does not include in composer.json #820
Comments
Anything I can do to get this fixed? As far as I see there's even a pull request waiting to be merged. |
I just need time to review #822. |
What would make things a bit easier for me would be feedback on whether #822 solves your problem. Thanks! |
✅ It does!First, I removed my workaround: diff --git a/src/main/php/unittest/coverage/impl/Coverage9.class.php ...
index d8861cd..989f450 100755
--- a/src/main/php/unittest/coverage/impl/Coverage9.class.php
+++ b/src/main/php/unittest/coverage/impl/Coverage9.class.php
@@ -7,25 +7,6 @@ use SebastianBergmann\CodeCoverage\Driver\Selector;
/** Coverage implementation for php-code-coverage >= 9.0 */
class Coverage9 extends Implementation {
- /** @codeCoverageIgnore */
- static function __static() {
-
- // Workaround for fatal error in php-code-coverage when PHPUnit is not loaded
- // See https://github.com/sebastianbergmann/php-code-coverage/issues/820
- if (!class_exists(BaseTestRunner::class)) {
- eval('namespace PHPUnit\Runner; class BaseTestRunner {
- const STATUS_UNKNOWN = -1;
- const STATUS_PASSED = 0;
- const STATUS_SKIPPED = 1;
- const STATUS_INCOMPLETE = 2;
- const STATUS_FAILURE = 3;
- const STATUS_ERROR = 4;
- const STATUS_RISKY = 5;
- const STATUS_WARNING = 6;
- }');
- }
- }
- ...and created a coverage report, reproducing the error: $ XP_RT=7.4x xp coverage -p src/main/php/ -r coverage-report/ src/test/php/
[............................Exception lang.Error (Class 'PHPUnit\Runner\BaseTestRunner' not found)
at <native>::Error(0, (0x2f)'Class 'PHPUnit\Runner\BaseTestRunner' not found') [line 994 of File.php]
# ... Next, I upgraded phpunit/php-code-coverage to ^9.2.2, which includes the fix: $ composer up
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating phpunit/php-code-coverage (9.2.1 => 9.2.3): Loading from cache
Writing lock file
Generating autoload files
4 packages you are using are looking for funding.
Use the `composer fund` command to find out more! ...and re-ran the above command, correctly producing the report. Thanks! |
When generating a HTML report using phpunit/php-code-coverage standalone, a fatal error occurs here:
This is due to the fact that the
switch
statement usesPHPUnit\Runner\BaseTestRunner
class constants but does not include a runtime dependency onphpunit/phpunit
.The text was updated successfully, but these errors were encountered: