Phpunit: Call to undefined method PHPUnit\Util\TestDox\CliTestDoxPrinter::colorizeTextBox() when using testdox

Created on 23 Oct 2019  路  13Comments  路  Source: sebastianbergmann/phpunit

| Q | A
| --------------------| ---------------
| PHPUnit version | 8.3.5
| PHP version | 7.3.10
| Installation Method | Composer

Summary

Testdox output option doesn't work.

Current behavior

When I run my tests with the --testdox flag it crashes unexpectedly with this message:

PHP Fatal error:  Uncaught Error: Call to undefined method PHPUnit\Util\TestDox\CliTestDoxPrinter::colorizeTextBox() in vendor/phpunit/phpunit/src/Util/TestDox/CliTestDoxPrinter.php:166

The class CliTestDoxPrinter extends from TestDoxPrinter which extends from ResultPrinter which implements colorizeTextBox method, so, I don't know why is this crashing.

How to reproduce

Just run phpunit with --testdox

Expected behavior

It should execute the test suit and output it with testdox format.

typbug

All 13 comments

It appears that you have different installations of PHPUnit mixed up.

For instance, you may have used Composer to install PHPUnit and have configured the autoloader generated by Composer as PHPUnit's bootstrap script but then you invoke PHPUnit using an executable other than vendor/bin/phpunit.

Yes, you're totally right. I have required phpunit/phpunit and symfony/phpunit-bridg in my composer.json, and I run tests via bin/phpunit instead of vendor/bin/phpunit. My fault! Thanks for your help @sebastianbergmann !

williamdes@williamdes:/mnt/Dev/@williamdes/mariadb-mysql-kbs$ composer run test
> phpunit --configuration ./test/phpunit.xml
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.

..................                                                18 / 18 (100%)

Time: 9.29 seconds, Memory: 18.00 MB

OK (18 tests, 34 assertions)

Generating code coverage report in Clover XML format ... done [51 ms]

Generating code coverage report in HTML format ... done [27 ms]
williamdes@williamdes:/mnt/Dev/@williamdes/mariadb-mysql-kbs$ ./vendor/bin/phpunit --configuration ./test/phpunit.xml --testdox
PHP Fatal error:  Uncaught Error: Call to undefined method PHPUnit\Util\TestDox\CliTestDoxPrinter::setShowProgressAnimation() in /mnt/Dev/@williamdes/mariadb-mysql-kbs/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:300
Stack trace:
#0 /mnt/Dev/@williamdes/mariadb-mysql-kbs/vendor/phpunit/phpunit/src/TextUI/Command.php(200): PHPUnit\TextUI\TestRunner->doRun()
#1 /mnt/Dev/@williamdes/mariadb-mysql-kbs/vendor/phpunit/phpunit/src/TextUI/Command.php(159): PHPUnit\TextUI\Command->run()
#2 /mnt/Dev/@williamdes/mariadb-mysql-kbs/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#3 {main}
  thrown in /mnt/Dev/@williamdes/mariadb-mysql-kbs/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 300

Removing --testdox fixed the issue on PHPUnit 8.5.2

@sebastianbergmann please re-open this issue

It also happens at phpMyAdmin

composer run phpunit -- --testdox

I will have a look as I implemented the colors and the spinner

@epdenouden There is no TestDox specific issue here. PHPUnit is invoked wrong, that's all.

@epdenouden There is no TestDox specific issue here. PHPUnit is invoked wrong, that's all.

What do you mean ?
It is a bug, right ?

It is a bug, right ?

I want to have a quick look, whether PHPUnit is invoked wrong or or not. There seems to be a mismatch between components: the TestRunner expects to be able to configure the spinner, which does not seem to be there.

@sebastianbergmann If it's and invoke issue, what could cause this? Different versions of PHPUnit clashing through autoloading strangeness?

For instance, Composer may have been used to install PHPUnit. Therefore the Composer-installed PHPUnit's source files are known to the Composer-generated autoloader. But then a globally installed PHPUnit, for instance, is invoked.

The commandline in https://github.com/sebastianbergmann/phpunit/issues/3906#issuecomment-578493458 reads

phpunit --configuration ./test/phpunit.xml

phpunit would be a globally installed PHPUnit where ./vendor/bin/phpunit should be used.

@sebastianbergmann see also: why you like PHAR :)

Now I'm going to dig into Composer a bit, see if it has a mechanism to guarantee all autoloaded classes come from the same origin.

Anyway thanks for the explanation. I'm off to @depends land

For instance, Composer may have been used to install PHPUnit. Therefore the Composer-installed PHPUnit's source files are known to the Composer-generated autoloader. But then a globally installed PHPUnit, for instance, is invoked.

The commandline in #3906 (comment) reads

phpunit --configuration ./test/phpunit.xml

phpunit would be a globally installed PHPUnit where ./vendor/bin/phpunit should be used.

williamdes@williamdes:/mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO$ composer run phpunit -- --testdox
> phpunit --color=always '--testdox'
PHP Fatal error:  Uncaught Error: Call to undefined method PHPUnit\Util\TestDox\CliTestDoxPrinter::setShowProgressAnimation() in /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:300
Stack trace:
#0 /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/Command.php(200): PHPUnit\TextUI\TestRunner->doRun()
#1 /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/Command.php(159): PHPUnit\TextUI\Command->run()
#2 /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#3 {main}
  thrown in /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 300
Script phpunit --color=always handling the phpunit event returned with error code 255
williamdes@williamdes:/mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO$ ./vendor/bin/phpunit --testdox
PHP Fatal error:  Uncaught Error: Call to undefined method PHPUnit\Util\TestDox\CliTestDoxPrinter::setShowProgressAnimation() in /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:300
Stack trace:
#0 /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/Command.php(200): PHPUnit\TextUI\TestRunner->doRun()
#1 /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/Command.php(159): PHPUnit\TextUI\Command->run()
#2 /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#3 {main}
  thrown in /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 300

@sebastianbergmann ./vendor/bin/phpunit --testdox throws the same error

I cannot think of a scenario where this can happen in an environment that is not mixed up. I cannot reproduce the issue.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Please do so in a new ticket. Then I can try to reproduce this again.

I cannot think of a scenario where this can happen in an environment that is not mixed up. I cannot reproduce the issue.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Please do so in a new ticket. Then I can try to reproduce this again.

It way very easy, done as https://github.com/sebastianbergmann/phpunit/issues/4097

Was this page helpful?
0 / 5 - 0 ratings