【问题标题】:phpunit running exception when run a very very simple unit test运行非常简单的单元测试时phpunit运行异常
【发布时间】:2013-09-22 01:21:22
【问题描述】:
  1. 我得到了 phpunit 并将其安装为 this link,使用最简单的方法进行测试。我只是下载 phpunit.phar 文件,chmod & rename & move to /usr/local/bin 然后,我运行phpunit --version,就ok了。

  2. 我写了一个简单的php测试用例。

    class SimpleTest extends PHPUnit_Framework_TestCase {
        public function testSomething(){
           $this -> assertTrue(true);
        }
    }
    
  3. 在终端中,我转到我的 php 类文件夹,然后执行

    phpunit --colors SimpleTest
    
  4. 现在我得到了例外

    PHP ReflectionException:  Method suite does not exist 
    in phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php on line 113
    
    PHP Stack trace:
    PHP   1. {main}() /usr/local/bin/phpunit:0
    
    PHP   2. PHPUnit_TextUI_Command::main($exit = *uninitialized*)
             /usr/local/bin/phpunit:612
    
    PHP   3. PHPUnit_TextUI_Command->run($argv = array (
             0 =>  '/usr/local/bin/phpunit', 
             1 => '--colors', 
             2 => 'SimpleTest.php'), 
             $exit = TRUE) 
            phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:129
    
    
    PHP   4. PHPUnit_Runner_BaseTestRunner->getTest(
           $suiteClassName = 'SimpleTest',   
           $suiteClassFile = '/home/kevin/Workspace/php/laravel/app/tests/SimpleTest.php',   
           $suffixes = array (0 => 'Test.php', 1 => '.phpt')) 
           phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:150
    
    PHP   5. ReflectionClass->getMethod('suite')    
    phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php:113
    
    PHPUnit 3.7.27 by Sebastian Bergmann.
    

欢迎任何事情,谢谢。

【问题讨论】:

  • 一点建议;运行它没有颜色 - 只是为了确定。并且:扩展类TestCase

标签: php laravel phpunit laravel-4


【解决方案1】:

看起来此错误来自 xdebug 设置。

解决方案似乎是将此行添加到您的 php.ini 文件中(或将现有值更改为 0):

xdebug.show_exception_trace = 0

看看 PHPUnit ReflectionException Method suite does not existWhy does PHPUnit hide my xdebug backtrace? 了解更多信息。

【讨论】:

  • 谢谢 J.T.是的,我关闭了这个配置,现在也不例外。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-07
  • 1970-01-01
  • 2013-01-20
  • 2011-06-06
  • 1970-01-01
  • 2012-03-02
相关资源
最近更新 更多