I am trying to get PHPUnit working in Netbeans. I was using 3.4.9 but that refused to work and it was suggested to upgrade to the latest version. I have now upgraded to 3.5.15 and when I run it I get the follo开发者_运维技巧wing message:
unrecognized option --log-xml
I understand that this is not a valid logging option, however I do not know where this is being set or how to change it. My phpunit.xml file is:
<phpunit bootstrap="./application/bootstrap.php" colors="true">
<testsuite name="Personal Development">
<directory>./</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../application/</directory>
<exclude>
<file>../application/Bootstrap.php</file>
<file>../application/controllers/ErrorController.php</file>
<directory suffix=".phtml">../application/</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8"
yui="true" highlight="true" lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="./log/testdox.html" />
</logging>
</phpunit>
How do I fix this error?
In order to force PHPUnit to use the correct files, I had to right click on the project name, Set Configuration, Customize, PHPUnit, then specify implicitly where the bootstrap and XML Config files were.
I encountered a similar problem using XAMPP, PHPUnit 3.5 and NetBeans 7. The problem is, that NetBeans for some reason always passes the option "--log-xml" to phpunit.bat, but this option does not exist in PHPUnit 3.5 any more.
My solution was to edit the PHPUnit configuration XML file: C:\xampp\php\PEAR\tests\MIME_Type\tests\phpunit.xml
(Note that the file path depends on the path your PEAR or PHPUnit installation is located!)
I had to append a new node, "logging":
<?xml version="1.0" encoding="utf-8"?>
<phpunit strict="true" colors="true"
bootstrap="bootstrap.php"
>
<filter>
<whitelist>
<directory suffix=".php">../MIME/</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="c:/xampp/tmp/logfile.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
After this change, NetBeans does not pass the "--log-xml" option anymore, but the "--log-junit" option, which is valid for PHPUnit 3.5. MyTests do now validate again. :-)
精彩评论