我的 PHPUnit 配置文件有两个测试套件,unit
and system
。当我运行测试运行程序时vendor/bin/phpunit
,它运行两个套件中的所有测试。我可以通过以下方式定位单个套件testsuite
flag: vendor/bin/phpunit --testsuite unit
,但我需要配置测试运行程序以仅运行unit
默认情况下套件,并运行integration
仅当使用 testsuite 标志专门调用时。
我的配置:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/clover.xml"/>
</logging>
</phpunit>
Since PHPUnit 6.1.0 https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-6.1.md#610---2017-04-07,现在支持defaultTestSuite
属性。
看一眼https://github.com/sebastianbergmann/phpunit/pull/2533 https://github.com/sebastianbergmann/phpunit/pull/2533
这可以与其他一起使用phpunit
像这样的属性:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.2/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
defaultTestSuite="unit"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory suffix="Test.php">tests/Integration</directory>
</testsuite>
</testsuites>
</phpunit>
您现在可以运行phpunit
代替phpunit --testsuite unit
.
测试套件的名称很可能区分大小写,因此请注意这一点。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)