diligent
diligent

Reputation: 2352

phpunit running exception when run a very very simple unit test

  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 .

Upvotes: 0

Views: 1420

Answers (1)

J.T. Grimes
J.T. Grimes

Reputation: 4272

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.

Upvotes: 1

Related Questions