phpunit.xml 用法
<testsuite name="actionsuitetest">
<directory suffix=".php">action</directory>
<file>HuiyuanZhanghuOrder.php</file>
<exclude>/action/HuiyuanJifenTest.php</exclude>
</testsuite><testsuite name="modelsuitetest">
<directory suffix=".php">model</directory>
</testsuite>
<testsuite name="htmlsuitetest">
<directory suffix=".php">html</directory>
</testsuite>
<!-- 代码覆盖率 -->
<!-- 覆盖率的测试文件,blacklist 黑名单(不需要统计覆盖率的文件),whitelist 白名单(统计覆盖率的测试文件) 当黑名单与白名单文件重复时,白名单起作用
-->
<filter>
<blacklist>
<directory suffix=".php">action</directory>
<file>ArrayTest.php</file>
</blacklist>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">action</directory>
<directory suffix=".php">model</directory>
<directory suffix=".php">html</directory>
<file>ArrayTest.php</file>
<exclude>
<directory suffix=".php">action/lib</directory>
<directory suffix=".php">model</directory>
<file>action/lib/Loginxxx.php</file>
</exclude>
</whitelist>
</filter>
<!--代码覆盖率报告,可以生成很多类型报告,有html(coverage-html),xml(coverage-clover),txt ,json 等等
<log type="coverage-php" target="/tmp/coverage.serialized"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
<log type="json" target="/tmp/logfile.json"/>
<log type="tap" target="/tmp/logfile.tap"/>
<log type="junit" target="/tmp/logfile.xml" logIncompleteSkipped="false"/>
<log type="testdox-html" target="/tmp/testdox.html"/>
<log type="testdox-text" target="/tmp/testdox.txt"/>
-->
<logging>
<!-- target(report/html) 生成html 文件的目录-->
<log type="coverage-html" target="report/html" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
<!-- target(report/coverage/coverage.xml) 生成xml的文件名-->
<log type="coverage-clover" target="report/coverage/coverage.xml"/>
</logging>
<!-- 代码覆盖率 -->
<includePath>.</includePath>
<ini name="foo" value="bar"/>
<const name="foo" value="bar"/>
<var name="foo" value="bar"/>
<env name="foo" value="bar"/>
<post name="foo" value="bar"/>
<get name="foo" value="bar"/>
<cookie name="foo" value="bar"/>
<server name="foo" value="bar"/>
<files name="foo" value="bar"/>
<request name="foo" value="bar"/>
</php>
</phpunit>
xml 解释
bootstrap="./booten.php"
在测试之前加载的的PHP 文件,一般可以做一个初始化工作
<testsuite name="actionsuitetest">
<directory suffix=".php">action</directory>
<file>HuiyuanZhanghuOrder.php</file>
</testsuite>
测试套件,如果想测试页面,action,model 可以多加几个测试套件
name: 套件名称
directory :套件测试的目录,目录下一般放测试文件的用例
suffix :测试文件后缀,如果不填写,则默认后缀为*Test.php,即phpunit 默认会执行*Test.php 的文件
action:测试目录名
file:可以单独设置测试文件
exclude:排除不需要测试的文件
<php>
<includePath>.</includePath>
<ini name="foo" value="bar"/>
<const name="foo" value="bar"/>
<var name="foo" value="bar"/>
<env name="foo" value="bar"/>
<post name="foo" value="bar"/>
<get name="foo" value="bar"/>
<cookie name="foo" value="bar"/>
<server name="foo" value="bar"/>
<files name="foo" value="bar"/>
<request name="foo" value="bar"/>
</php>
这段xml 可以对应以下PHP 代码
includePath
ini_set('foo', 'bar');
define('foo', 'bar');
$GLOBALS['foo'] = 'bar';
$_ENV['foo'] = 'bar';
$_POST['foo'] = 'bar';
$_GET['foo'] = 'bar';
$_COOKIE['foo'] = 'bar';
$_SERVER['foo'] = 'bar';
$_FILES['foo'] = 'bar';
$_REQUEST['foo'] = 'bar';
phpunit.xml 应用网址http://www.phpunit.de/manual/3.6/en/appendixes.configuration.html#appendixes.configuration.blacklist-whitelist
版权声明:本文为博主原创文章,未经博主允许不得转载。