gpt4 book ai didi

php - Symfony2 中的 PHPUnit 错误

转载 作者:可可西里 更新时间:2023-11-01 13:26:29 24 4
gpt4 key购买 nike

我在使用 Symfony2 时遇到 PHPUnit 错误

在我的测试用例中,我导入:

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

但是,当我执行它时,我得到:

PHP Fatal error:  Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in C:\trabajo\web\Company\src\Company\WebBundle\Tests\dbTest.php on line 11

我用来执行它:

phpunit -c app/ src/Company/WebBundle/Tests/dbTest

有什么帮助吗?

提前致谢。

最佳答案

这是因为要使用 CLI 执行测试用例,您需要提供

  • 引导文件 /app/bootstrap.php.cache
  • 配置文件app/phpunit.xml.dist

所以命令如下:

phpunit --configuration app/phpunit.xml.dist ----bootstrap /app/bootstrap.php.cache

Bootstrap 可以在 phpunit.xml.dist 中提供,也可以在 <phpunit> 中提供。标签。

假设您有良好的 phpunit.xml.dist 文件,另一种选择是转到应用程序目录并在那里执行测试。

您可以根据需要调整路径。

关于php - Symfony2 中的 PHPUnit 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17744136/

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