简体   繁体   中英

Developing PHPUnit: how to run its tests

I want to play around with changing PHPUnit's source, but first I'd like to be able to run its tests to make sure I don't break anything.

I used git to get version 4.7.7 out into a directory. In that directory, I then ran composer install .

Then I cd into tests and run:

phpunit --bootstrap ./bootstrap.php ./

(The version of PHPUnit I'm using to run the tests is also 4.7.7.)

but I get this:

PHP Fatal error:  Uncaught exception 'Exception' with message 'PHPUnit suppresses exceptions thrown outside of test case function' in C:\Users\jodes\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php:7
Stack trace:
#0 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(52): include_once()
#1 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(36): PHPUnit_Util_Fileloader::load('C:\Users\jody\D...')
#2 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(334): PHPUnit_Util_Fileloader::checkAndLoad('C:\Users\jody\D...')
#3 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(406): PHPUnit_Framework_TestSuite->addTestFile('C:\Users\jody\D...')
#4 phar://C:/phpbin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(57): PHPUnit_Framework_TestSuite->addTestFiles(Array)
#5 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(121): PHPUnit_Runner_BaseTestRunner->getTest('.\tests\', '', Array)
#6 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(99): PHPUnit_TextU in C:\Users\jody\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php on line 7

Fatal error: Uncaught exception 'Exception' with message 'PHPUnit suppresses exceptions thrown outside of test case function' in C:\Users\jodes\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php:7
Stack trace:
#0 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(52): include_once()
#1 phar://C:/phpbin/phpunit.phar/phpunit/Util/Fileloader.php(36): PHPUnit_Util_Fileloader::load('C:\Users\jody\D...')
#2 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(334): PHPUnit_Util_Fileloader::checkAndLoad('C:\Users\jody\D...')
#3 phar://C:/phpbin/phpunit.phar/phpunit/Framework/TestSuite.php(406): PHPUnit_Framework_TestSuite->addTestFile('C:\Users\jody\D...')
#4 phar://C:/phpbin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(57): PHPUnit_Framework_TestSuite->addTestFiles(Array)
#5 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(121): PHPUnit_Runner_BaseTestRunner->getTest('.\tests\', '', Array)
#6 phar://C:/phpbin/phpunit.phar/phpunit/TextUI/Command.php(99): PHPUnit_TextU in C:\Users\jody\Documents\NetBeansProjects\PHPUnit\phpunit\tests\Regression\GitHub\873\Issue873Test.php on line 7

What am I doing wrong? Thanks

If your class "Success" have a namespace, you better use your autoloader with phpunit's --bootstrap parameter

if this situation is related with autoloading, you maybe want to read http://jes.st/2011/phpunit-bootstrap-and-autoloading-classes/ (an old one, but a clear one)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM