我想在 Symfony 中为我的捆绑测试运行 phpunit 测试,我尝试过以下方式:
phpunit --verbose src\MyNameSpace\MyAppBundle\Tests\Controller\BadDataPostUnitTestControllerTest
但我看到的错误: 致命错误:类'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in...我在我的测试类中使用它的地方
我正在从 Windows 命令提示符运行命令并从 Symfony 根目录运行命令
存在的作曲家依赖项,我检查了 composer.json 文件是否存在以下几行:
,
"require-dev": {
"sensio/generator-bundle": "~2.3",
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "^2.3",
"phploc/phploc": "^2.1",
"pdepend/pdepend": "^2.1",
"phpmd/phpmd": "^2.2",
"sebastian/phpcpd": "^2.0",
"theseer/phpdox": "0.8.1.1",
"symfony/browser-kit": "^2.7",
"mayflower/php-codebrowser": "^1.1"
}
更新:虽然 --verbose 显示错误,但以下命令运行正常: phpunit -c app /src/NameSpace/MyBundle/Tests/Controller/MyUnitTestControllerTest.php
更新:
/app/phpunit.xml 文件:
<phpunit backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" bootstrap="bootstrap.php.cache" codecoverage="true">
<formatter type="clover" usefile="false"/>
<testsuites>
<testsuite name="EDS Console App Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
</testsuite>
</testsuites>
<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>
<php>
<server name='SERVER_PORT' value='8080' />
<server name='SERVER_NAME' value='http://myserver.com' />
</php>
<logging>
<log type="coverage-html" target="${basedir}/build/coverage" title="EDL-Console Test Coverage" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="${basedir}/build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>