gpt4 book ai didi

php - Symfony3 phpunit xml

转载 作者:可可西里 更新时间:2023-10-31 22:40:59 24 4
gpt4 key购买 nike

嘿,在我的 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>

所以现在它工作正常,但我找不到开放答案的问题是:

  1. 为什么 php unit 需要这个文件我可以看到文件显示 phpunit 在哪里寻找测试但仅此而已吗?

  2. 我手动创建了这个文件,有没有办法像使用终端命令一样自动创建它。

  3. 据我了解<whitelist> phpunit 在哪里可以“看”?和 <exlude>它不允许phpunit“看”的地方?如果是这样,那为什么会 <directory>../src/*/*Bundle/Tests</directory><exlude>如果那是测试的地方。

最佳答案

使用新的 symfony3 目录结构,PHPUnit 配置文件位于项目的根目录中,因此您不再需要指定 -c 参数(配置)。所以你可以简单地启动如下:

>bin/phpunit

希望对你有帮助

关于php - Symfony3 phpunit xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37654740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com