jepster
(4004ar)
April 16, 2015, 7:11am
1
Hi,
I want to run a single PHPUnit test by adapting the phpunit.xml.dist file, which is included in YIi2. My current PHPUnit XML file looks that way:
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/unit/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Yii Test Suite">
<file>./tests/unit/framework/base/ActiveFilterTest.php</file>
</testsuite>
</testsuites>
</phpunit>
It is located in the same folder like the phpunit.xml.dist file, which is shipped with Yii2 and works on my system.
How must be my configuration above modified, so that I can run a single test like f.e. /tests/unit/framework/base/ActiveFilterTest.php?
Currently I’m getting the following error message in my PHPStorm IDE (please note that the phpunit.xml.dist configuration works already):
PHPUnit 3.7.10 by Sebastian Bergmann.
Configuration read from /Users/jepster/Sites/yii2/custom_phpunit.xml.dist
Time: 136 ms, Memory: 3.50Mb
No tests executed!
Fatal error: Call to undefined method PHPUnit_Framework_TestResult::deprecatedFeaturesCount() in phar:///Applications/phpunit-3.7.10.phar/PHPUnit/TextUI/ResultPrinter.php on line 446
Call Stack:
0.0037 351024 1. {main}() /private/var/folders/cg/3g3ddv1x77j41vfhysd395q40000gn/T/ide-phpunit.php:0
0.0658 1057064 2. IDE_Base_PHPUnit_TextUI_Command::main() /private/var/folders/cg/3g3ddv1x77j41vfhysd395q40000gn/T/ide-phpunit.php:516
0.0658 1057688 3. PHPUnit_TextUI_Command->run() /private/var/folders/cg/3g3ddv1x77j41vfhysd395q40000gn/T/ide-phpunit.php:258
0.1302 3407768 4. PHPUnit_TextUI_TestRunner->doRun() phar:///Applications/phpunit-3.7.10.phar/PHPUnit/TextUI/Command.php:176
0.1354 3575520 5. IDE_PHPUnit_TextUI_ResultPrinter->printResult() /Users/jepster/Sites/yii2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:412
0.1362 3589984 6. PHPUnit_TextUI_ResultPrinter->printFooter() /private/var/folders/cg/3g3ddv1x77j41vfhysd395q40000gn/T/ide-phpunit.php:247
First off: Rename your [font=“Courier New”]custom_phpunit.xml.dist[/font] to [font=“Courier New”]phpunit.xml[/font]. It’s going to take precedence over [font=“Courier New”]phpunit.xml.dist[/font] and will make your life much easier. Now from the same directory simply call this:
phpunit /tests/unit/framework/base/ActiveFilterTest.php
I’m also puzzled why phpunit doesn’t find your test in the first place. Running PHPUnit with [font=“Courier New”]–verbose[/font] and/or [font=“Courier New”]–debug[/font] may be more revealing on what’s going on here.
jepster
(4004ar)
April 19, 2015, 8:17pm
3
First off: Rename your [font=“Courier New”]custom_phpunit.xml.dist[/font] to [font=“Courier New”]phpunit.xml[/font]. It’s going to take precedence over [font=“Courier New”]phpunit.xml.dist[/font] and will make your life much easier. Now from the same directory simply call this:
phpunit /tests/unit/framework/base/ActiveFilterTest.php
I’m also puzzled why phpunit doesn’t find your test in the first place. Running PHPUnit with [font=“Courier New”]–verbose[/font] and/or [font=“Courier New”]–debug[/font] may be more revealing on what’s going on here.
Thanks for your reply, but it doesn’t work.
If I follow your steps, the output is the following:
phpunit tests/unit/framework/base/ActionFilterTest.php --verbose --debug
Fatal error: require_once(): Failed opening required ‘/Users/jepster/Sites/yii2/tests/unit/../../../../autoload.php’ (include_path=’.:/Applications/MAMP/bin/php/php5.6.7/lib/php’) in /Users/jepster/Sites/yii2/tests/unit/bootstrap.php on line 16
Call Stack:
0.0033 297032 1. {main}() /Applications/phpunit-3.7.10.phar:0
0.0434 700256 2. PHPUnit_TextUI_Command::main() /Applications/phpunit-3.7.10.phar:523
0.0435 700880 3. PHPUnit_TextUI_Command->run() phar:///Applications/phpunit-3.7.10.phar/PHPUnit/TextUI/Command.php:129
0.0435 703288 4. PHPUnit_TextUI_Command->handleArguments() phar:///Applications/phpunit-3.7.10.phar/PHPUnit/TextUI/Command.php:138
0.0535 1049624 5. PHPUnit_TextUI_Command->handleBootstrap() phar:///Applications/phpunit-3.7.10.phar/PHPUnit/TextUI/Command.php:606
0.0537 1058112 6. PHPUnit_Util_Fileloader::checkAndLoad() phar:///Applications/phpunit-3.7.10.phar/PHPUnit/TextUI/Command.php:778
0.0538 1058288 7. PHPUnit_Util_Fileloader::load() phar:///Applications/phpunit-3.7.10.phar/PHPUnit/Util/Fileloader.php:76
0.0540 1063872 8. include_once('/Users/jepster/Sites/yii2/tests/unit/bootstrap.php') phar:///Applications/phpunit-3.7.10.phar/PHPUnit/Util/Fileloader.php:92