大家好,我已经在我的Symfony3项目中安装了PhpUnit,在终端中运行bin/phpunit -c app时出现了以下错误:
Could not load XML from empty string
我在谷歌上搜索了一下,发现我需要在我的app/目录下添加一个phpunit.xml文件,于是我这样做了,它看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "autoload.php" >
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<!--directory>../src/*/Bundle/*Bundle/Tests</directory-->
</testsuite>
</testsuites>
<!--
<php>
<server name="KERNEL_DIR" value="/path/to/your/app/" />
</php>
-->
<filter>
<whitelist>
<directory>../src</directory>
<exclude>
<directory>../src/*/*Bundle/Resources</directory>
<directory>../src/*/*Bundle/Tests</directory>
<!--directory>../src/*/Bundle/*Bundle/Resources</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory-->
</exclude>
</whitelist>
</filter>
</phpunit>
现在它能正常工作了,但我找不到答案的问题是:
为什么php unit需要这个文件?我知道这个文件告诉phpunit在哪里寻找测试,但只有这些吗?
我手动创建了这个文件,是否有一种自动创建它的方式,比如使用终端命令?
据我所知,
<whitelist>
是phpunit被允许“查找”的地方?而<exlude>
则是phpunit禁止“查找”的地方?如果是这样的话,那为什么这个<directory>../src/*/*Bundle/Tests</directory>
会在<exlude>
中,而那里是测试的位置。
.dist
文件。关于自动重命名,您可能需要使用脚本。请查看Incenteev/ParameterHandler。这是用于Symfony2parameters.yml.dist
文件的捆绑包。 - ferdynator