我在 PHPUnit 中查找错误源时遇到问题。如果我在没有过滤器的情况下运行phpunit,我将收到"字节耗尽"错误。但是,如果我使用 phpunit --filter test_name 一次运行一个测试 - 我的所有测试都将通过。
下面发布的堆栈跟踪表明我的一个名为 KInit 的测试存在问题,但是如果单独运行该测试,则一切都会通过。我也尝试将测试移出目录,但错误只会指向下一个运行的测试。我也尝试过使用 sudo 运行,但效果不佳。我怎样才能获得有关这里发生的事情的更多信息?
我正在运行 PHPUint 来测试 laravel 4.2 应用程序。东西的版本PHPUnit 4.1.4菲律宾比索 5.5.18Ubuntu 12.04 64 位
下面的堆栈跟踪显示错误在:
laravel/framework/src/Illuminate/Filesystem/Filesystem.php
但是有时它读
/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
全栈跟踪:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 15886 bytes) in /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 31
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:586
PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:132
PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:179
PHP 5. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:426
PHP 6. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 7. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 8. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 9. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:758
PHP 10. PHPUnit_Framework_TestCase->runBare() phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php:686
PHP 11. KInitTest->setUp() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:818
PHP 12. TestCase->setUp() /opt/pplus/laravel/app/tests/unit/classes/KInit/KInitTest.php:16
PHP 13. Illuminate'Foundation'Testing'TestCase->setUp() /opt/pplus/laravel/app/tests/TestCase.php:35
PHP 14. Illuminate'Foundation'Testing'TestCase->refreshApplication() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:31
PHP 15. TestCase->createApplication() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:42
PHP 16. require() /opt/pplus/laravel/app/tests/TestCase.php:17
PHP 17. require() /opt/pplus/laravel/bootstrap/start.php:60
PHP 18. Illuminate'Foundation'ProviderRepository->load() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/start.php:210
PHP 19. Illuminate'Foundation'ProviderRepository->loadManifest() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:51
PHP 20. Illuminate'Filesystem'Filesystem->get() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:187
PHP 21. file_get_contents() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:31
我找到了答案。我不得不增加/etc/php5/cli/php.ini 中的memory_limit。我总是忘记phpunit使用与apache不同的ini文件。