Why will PHPUnit not accept an XML defined test suite?
I'm following along on the ZendCast
for writing unit tests on top of the Zend Framework. Between the video and a few other sources, my phpunit.xml
looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./application/bootstrap.php" colors="true">
<testsuites>
<testsuite name="RefreshTests">
<directory>./</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".ph开发者_C百科p">../application</directory>
</whitelist>
<exclude></exclude>
</filter>
<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8"
yui="true" highlight="true" lowUpperBound="50" highLowerBound="80" />
<log type="testdox" target="./log/testdox.html" />
</logging>
</phpunit>
Unfortunately, when I try to run PHPUnit with this file, while I can verify that the "boostrap.php" file does, run, I get this error at runtime:
PHPUnit_Framework_Exception: Neither "RefreshTests.php" nor "RefreshTests.php" could be opened. in C:\Program Files (x86)\php\pear\PHPUnit\Util\Skeleton\Test.php on line 102
This seems to indicate that PHPUnit is looking for a file based on what I named the test suite in order to find the tests to run, instead of respecting my wishes to have it run against the entire directory. This despite that PHPUnit's documentation quite explicitly says that defining a test suite this way is allowed.
What have I done incorrectly?
The error means that phpunit can't find any test class within the "."
directory while scanning it recursively.
If it can't find any test files it then tries to open a .php file named like the testsuite. Hence the error.
Make sure your TestClasses end in Test.php
or add a suffix=".php"
(or whatever) to your <directory>
tag and make sure that file contains a class that also ends in Test
.
精彩评论