Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPunit Code Coverage error

PHPunit is working, but I get this code coverage error and don't get the code coverage report.

Does anyone know how to fix this?

Thanks,

Demian.

demian@dimbo-TP:/var/www/z2d2/tests$ phpunit
PHPUnit 3.5.15 by Sebastian Bergmann.

...

Time: 1 second, Memory: 13.00Mb

OK (3 tests, 4 assertions)

Generating code coverage report, this may take a moment.PHP Fatal error:  Class 'PHP_Token_Stream' not found in /usr/share/php/PHP/Token/Stream/CachingFactory.php on line 68
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:49
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
PHP   5. PHP_CodeCoverage_Report_HTML->process() /usr/share/php/PHPUnit/TextUI/TestRunner.php:363
PHP   6. PHP_CodeCoverage_Report_HTML->addItems() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:135
PHP   7. PHP_CodeCoverage_Report_HTML_Node_Directory->addFile() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:214
PHP   8. PHP_CodeCoverage_Report_HTML_Node_File->__construct() /usr/share/php/PHP/CodeCoverage/Report/HTML/Node/Directory.php:156
PHP   9. PHP_CodeCoverage_Util::getLinesToBeIgnored() /usr/share/php/PHP/CodeCoverage/Report/HTML/Node/File.php:169
PHP  10. PHP_Token_Stream_CachingFactory::get() /usr/share/php/PHP/CodeCoverage/Util.php:271

Fatal error: Class 'PHP_Token_Stream' not found in /usr/share/php/PHP/Token/Stream/CachingFactory.php on line 68

Call Stack:
    0.0002     326940   1. {main}() /usr/bin/phpunit:0
    0.0434     666604   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:49
    0.0435     667084   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
    0.0943    4312004   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
    1.1150   13272196   5. PHP_CodeCoverage_Report_HTML->process() /usr/share/php/PHPUnit/TextUI/TestRunner.php:363
    1.1521   14100768   6. PHP_CodeCoverage_Report_HTML->addItems() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:135
    1.1521   14101320   7. PHP_CodeCoverage_Report_HTML_Node_Directory->addFile() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:214
    1.1521   14103132   8. PHP_CodeCoverage_Report_HTML_Node_File->__construct() /usr/share/php/PHP/CodeCoverage/Report/HTML/Node/Directory.php:156
    1.1595   14122724   9. PHP_CodeCoverage_Util::getLinesToBeIgnored() /usr/share/php/PHP/CodeCoverage/Report/HTML/Node/File.php:169
    1.1595   14123076  10. PHP_Token_Stream_CachingFactory::get() /usr/share/php/PHP/CodeCoverage/Util.php:271
like image 437
dimbo Avatar asked Nov 14 '11 15:11

dimbo


1 Answers

You are running PHPUnit 3.5.x so the Token stream version you need can be installed using:

sudo pear install --force --alldeps phpunit/PHP_CodeCoverage-1.0.2

If you want to update to the current version of phpunit something alone the lines of

sudo pear install --force --alldeps phpunit/phpunit

will do the job but if i remember correctly you are trying to use the Zend Framework testing environment and that only works with PHPUnit 3.5.15


If both options fail or are not suitable go for

sudo pear install --force phpunit/PHP_TokenStream

What will definitely get you a working PHPUnit 3.5.15

http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/

Important note: if you install PHPUnit via PEAR. This installation method is no longer supported and http://pear.phpunit.de/ will be shut down no later than December, 31 2014.

Please read http://phpunit.de/manual/current/en/installation.html and learn how to use PHPUnit from a PHAR or install it via Composer.

like image 185
edorian Avatar answered Sep 22 '22 07:09

edorian