Mic*_*ael 4 phpunit functional-testing symfony
这是我的 phpunit.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="true"
strict="true"
bootstrap="./vendor/autoload.php">
<testsuites>
<php>
<server name="KERNEL_DIR" value="app" />
<ini name="display_errors" value="true"/>
</php>
<testsuite name="Functional Tests">
<directory>./tests/src/myApp/AppBundle/functional</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
这是测试类
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class MyTest extends WebTestCase
{
private $client;
public function setUp()
{
$this->client = static::createClient();
}
Run Code Online (Sandbox Code Playgroud)
运行测试时,我得到了 setUp 中的一行:
根据https://symfony.com/doc/current/book/testing.html#your-first-functional-test在 phpunit.xml 中设置 KERNEL_DIR 或覆盖 WebTestCase::createKernel() 方法
将块<php> ... </php>移出<testsuites>...到它自己的顶层。
这是我自己的主要项目的精简副本:
<phpunit
bootstrap = "app/bootstrap_test.php"
verbose = "true"
>
<php>
<ini name="memory_limit" value="-1" />
<!-- <server name="KERNEL_DIR" value="./app/" /> older-style -->
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>
<testsuites>
<testsuite name="project.name">
<directory suffix=".php">./src/*Bundle</directory>
<directory suffix=".php">./src/AppBundle</directory> -->
<directory>./tests/App</directory>
</testsuite>
</testsuites>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7017 次 |
| 最近记录: |