[英]PHPunit Code Coverage error
PHPunit正在運行,但我收到此代碼覆蓋率錯誤,並且沒有獲得代碼覆蓋率報告。
有誰知道如何解決這一問題?
謝謝,
德棉。
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
您正在運行PHPUnit 3.5.x,因此可以使用以下命令安裝所需的令牌流版本:
sudo pear install --force --alldeps phpunit/PHP_CodeCoverage-1.0.2
如果你想更新到當前版本的phpunit那么單獨的行
sudo pear install --force --alldeps phpunit/phpunit
將完成這項工作,但如果我沒記錯的話,你正在嘗試使用Zend Framework測試環境並且只適用於PHPUnit 3.5.15
如果兩個選項都失敗或不適合
sudo pear install --force phpunit/PHP_TokenStream
http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/
重要說明 :如果您通過PEAR安裝PHPUnit。 不再支持此安裝方法,並且將在2014年12月31日之前關閉http://pear.phpunit.de/ 。
請閱讀http://phpunit.de/manual/current/en/installation.html並了解如何從PHAR使用PHPUnit或通過Composer安裝它。
如果所有努力降級phpunit 3.6到3.5都沒有成功。 您可以通過將以下代碼添加到/usr/share/php/PHP/Token/Stream/CachingFactory.php來修復此問題,以修復“找不到類'PHP_Token_Stream'...”
require_once('PHP/Token/Stream/Autoload.php');
嘗試通過重新安裝修復phpunit:
$ pear upgrade -f phpunit
用pear安裝phpunit對我來說根本不起作用。
我最終做的是(在某些目錄中,例如/ home / USERNAME / phpunit ):
wget http://pear.phpunit.de/get/phpunit.phar
chmod +x phpunit.phar
並在.bash.rc中添加結尾
export PATH=${PATH}:PATH_WHERE_YOU_PUT_phpunit.phar
在我的例子中,PATH_WHERE_YOU_PUT_phpunit.phar將是/ home / USERNAME / phpunit
之后,phpunit可以在任何目錄中使用命令phpunit.phar執行
某些Linux發行版的選項可能是使用yum或apt-get來安裝phpunit。
我正在使用Fedora 17並安裝了phpunit和yum,一切都運行正常。 不確定Ubuntu / Mint包的工作情況。
在Windows中,我使用梨,它在那里工作得很好但是因為我發現了yum中的phpunit,我想我先試試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.