XML文件配置項
convertErrorsToExceptions
將PHP的錯誤提示轉換爲異常。支持轉換的錯誤有:
E_WARNING
E_NOTICE
E_USER_ERROR
E_USER_WARNING
E_USER_NOTICE
E_STRICT
E_RECOVERABLE_ERROR
E_DEPRECATED
E_USER_DEPRECATED
將
convertErrorsToExceptions
設爲false
可以禁用此功能。
convertNoticesToExceptions
此選項設置爲
false
時,由convertErrorsToExceptions
安插的錯誤處理函數不會將E_NOTICE
、E_USER_NOTICE
、E_STRICT
錯誤轉換爲異常。
convertWarningsToExceptions
此選項設置爲
false
時,由convertErrorsToExceptions
安插的錯誤處理函數不會將E_WARNING
或E_USER_WARNING
錯誤轉換爲異常。
forceCoversAnnotation
只記錄使用了
@covers
標註的測試的代碼覆蓋率。
timeoutForLargeTests/timeoutForMediumTests/timeoutForSmallTests
結合有風險的測試理解。
測試套件
testsuite/testsuites/directory/file/exclude
<testsuites>
<testsuite name="My Test Suite">
<directory>/path/to/*Test.php files</directory>
<file>/path/to/MyTest.php</file>
<exclude>/path/to/exclude</exclude>
</testsuite>
</testsuites>
exclude
是排除的意思。directory
,file
,exclude
的目的都是一樣的,就是指定測試套件的地址。
phpVersion/phpVersionOperator
可以用
phpVersion
和phpVersionOperator
屬性來指定 PHP 版本需求。在以下例子中,僅當 PHP 版本至少爲 5.3.0 時纔會將/path/to/*Test.php
文件與/path/to/MyTest.php
文件添加到測試套件中。
phpVersionOperator
屬性是可選的,其默認值爲>=
。
<testsuites>
<testsuite name="My Test Suite">
<directory suffix="Test.php" phpVersion="5.3.0" phpVersionOperator=">=">/path/to/files</directory>
<file phpVersion="5.3.0" phpVersionOperator=">=">/path/to/MyTest.php</file>
</testsuite>
</testsuites>
group/include/exclude
<groups>
元素及其<include>
、<exclude>
、<group>
子元素用於從帶有@group
標註的測試中選擇需要運行(或不運行)的分組。
<groups>
<include>
<group>name</group>
</include>
<exclude>
<group>name</group>
</exclude>
</groups>
以上配置跟命令行參數
--group name
--exclude-group name
的效果是一樣的。
代碼覆蓋率白名單
filter/whitelist/directory/file/exclude
<filter>
元素及其子元素用於配置代碼覆蓋率報告所使用的白名單。
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">/path/to/files</directory>
<file>/path/to/file</file>
<exclude>
<directory suffix=".php">/path/to/files</directory>
<file>/path/to/file</file>
</exclude>
</whitelist>
</filter>
日誌記錄
logging/log
<logging>
<log type="coverage-html" target="/tmp/report" lowUpperBound="35"
highLowerBound="70"/>
<log type="coverage-clover" target="/tmp/coverage.xml"/>
<log type="coverage-php" target="/tmp/coverage.serialized"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
<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>
以上配置跟命令行的以下參數是一致的:
--coverage-html /tmp/report
--coverage-clover /tmp/coverage.xml
--coverage-php /tmp/coverage.serialized
--coverage-text
> /tmp/logfile.txt
--log-junit /tmp/logfile.xml
--testdox-html /tmp/testdox.html
--testdox-text /tmp/testdox.txt
lowUpperBound
:視爲“低”覆蓋率的最大覆蓋率百分比。highLowerBound
:視爲“高”覆蓋率的最小覆蓋率百分比。showUncoveredFiles
:在--coverage-text
輸出中顯示所有符合白名單的文件,不僅限於有覆蓋率信息的那些。showOnlySummary
:在--coverage-text
輸出中只顯示摘要。
測試監聽器
關於監視器的內容沒有找到,先空着吧。
listerners/listerner
<listeners>
元素及其<listener>
子元素用於在測試執行期間附加額外的測試監聽器。
<listeners>
<listener class="MyListener" file="/optional/path/to/MyListener.php">
<arguments>
<array>
<element key="0">
<string>Sebastian</string>
</element>
</array>
<integer>22</integer>
<string>April</string>
<double>19.78</double>
<null/>
<object class="stdClass"/>
</arguments>
</listener>
</listeners>
設定 PHP INI 設置、常量、全局變量
<php>
元素及其子元素用於配置 PHP 設置、常量以及全局變量。同時也可用於向include_path
前部置入內容。
<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 代碼:
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';