Symfony2中PHPUnit出错

时间:2013-07-19 10:40:38

标签: php symfony phpunit

我使用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

任何帮助?

提前致谢。

2 个答案:

答案 0 :(得分:2)

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

  • boostrap文件/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文件的另一个选择是去app目录并执行测试。

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

答案 1 :(得分:1)

检查是否扩展了dbTest类:

<?php

namespace Company\WebBundle\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class dbTest extends WebTestCase
{
    ...
}
相关问题