2015-01-16 162 views
-1

我遇到问题,发现我在PHPUnit中收到的错误的来源。如果我运行phpunit没有过滤器,我会收到“字节穷尽”的错误。但是,如果我使用phpunit --filter test_name一次运行一个测试,则所有测试都会通过。跟踪PHPUnit错误

下面发布的堆栈跟踪表明我的一个测试名为KInit的问题,但是如果运行该测试本身一切都会通过。 我也尝试将测试移出目录,但错误将仅指向正在运行的下一个测试。我也尝试用sudo运行,但这并没有奏效。 如何获得更多关于这里发生的事情的信息?

我正在运行PHPUint来测试laravel 4.2应用程序。 版本的东西 PHPUnit的4.1.4 PHP 5.5.18 的Ubuntu 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 

回答

1

我找到了答案。我不得不增加/etc/php5/cli/php.ini中的memory_limit。我总是忘记phpunit使用的是不同于apache的ini文件。