0
  1. I get phpunit and install it as this link using the simplest way for test purposes. I just download the phpunit.phar file, chmod & rename & move to /usr/local/bin Then, I run phpunit --version, its ok.

  2. I write a simple php test case.

    class SimpleTest extends PHPUnit_Framework_TestCase {
        public function testSomething(){
           $this -> assertTrue(true);
        }
    }
    
  3. In terminal , I go to my php class folder, and execute

    phpunit --colors SimpleTest
    
  4. Now I got the exceptions

    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.
    

Anything is welcome, thanks .

4

1 回答 1

1

It looks like this error comes from an xdebug setting.

The solution appears to be adding this line to your php.ini file (or changing your the existing value to 0):

xdebug.show_exception_trace = 0

Take a look at PHPUnit ReflectionException Method suite does not exist and Why does PHPUnit hide my xdebug backtrace? for more info.

于 2013-09-17T15:45:27.903 回答