| Prev | Next |
<phpunit> 要素の属性を使って PHPUnit のコア機能を設定します。
<phpunit backupGlobals="true"
backupStaticAttributes="false"
<!--bootstrap="/path/to/bootstrap.php"-->
cacheTokens="true"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
<!--printerFile="/path/to/ResultPrinter.php"-->
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
<!--testSuiteLoaderFile="/path/to/StandardTestSuiteLoader.php"-->
strict="false"
verbose="false">
<!-- ... -->
</phpunit>
上の XML 設定ファイルは、TextUI テストランナーをデフォルトの設定で起動します。 その詳細は 「Command-Line switches」 で説明します。
その他、コマンドラインからは設定できないオプションもあります。
convertNoticesToExceptions, convertWarningsToExceptions, convertErrorsToExceptions
これらを使うと、PHP の error/warning/notice の例外への自動変換を止めることができます。
forceCoversAnnotation
コードカバレッジの記録を、 @covers アノテーションを使っている関数だけに限定します。 このアノテーションについては 「@covers」 で説明します。
<testsuites> 要素とその子要素である <testsuite> を使って、 テストスイート群やテストケース群の中からテストスイートを構成します。
<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>
phpVersion および phpVersionOperator 属性を使うと、必要な PHP のバージョンを指定できます。次の例は、PHP のバージョンが 5.3.0 以降である場合にのみ /path/to/*Test.php と /path/to/MyTest.php を追加します。
<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>
phpVersionOperator 属性はオプションで、デフォルトは >= です。
<groups> 要素とその子要素である <include>、 <exclude> および <group> を使って、 テストスイートの中から実行する (しない) テストグループを選びます。
<groups>
<include>
<group>name</group>
</include>
<exclude>
<group>name</group>
</exclude>
</groups>
上の XML 設定ファイルは、 TextUI テストランナーを以下の引数で起動します。
--group name
--exclude-group name
<filter> 要素とその子要素を使って、 コードカバレッジレポートのブラックリストとホワイトリストを設定します。
<filter>
<blacklist>
<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>
</blacklist>
<whitelist addUncoveredFilesFromWhitelist="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" charset="UTF-8"
yui="true" highlight="false"
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="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>
上の XML 設定ファイルは、 TextUI テストランナーを以下の引数で起動します。
--coverage-html /tmp/report
--coverage-clover /tmp/coverage.xml
--coverage-php /tmp/coverage.serialized
--coverage-text
--log-json /tmp/logfile.json
> /tmp/logfile.txt
--log-tap /tmp/logfile.tap
--log-junit /tmp/logfile.xml
--testdox-html /tmp/testdox.html
--testdox-text /tmp/testdox.txt
charset、yui、 highlight、lowUpperBound、 highLowerBound、logIncompleteSkipped および showUncoveredFiles 属性には、TextUI テストランナーで対応するスイッチがありません。
charset: 生成する html ページで使う文字セット。
yui: html カバレッジレポートを yui ライブラリで強化する。たとえば、 行番号をクリックすると YUI パネルが現れて、その行をカバーするすべてのメソッドを一覧表示します。
highlight: true にすると、カバレッジレポート内のコードにシンタックスハイライト処理を施します。
lowUpperBound: カバー率がこの値に満たないときに、カバー率が '低い' とみなします。
highLowerBound: カバー率がこの値を超えるときに、カバー率が '高い' とみなします。
showUncoveredFiles: カバレッジ情報を含むファイルだけでなく、ホワイトリスト内のすべてのファイルを --coverage-text の出力に含めます。
<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>
上の XML 設定は、 $listener オブジェクト (以下を参照ください) をテストの実行時にアタッチします。
$listener = new MyListener(
array('Sebastian'),
22,
'April',
19.78,
NULL,
new stdClass
);
<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';
<selenium> 要素とその子要素である <browser> を使って、 Selenium RC サーバのリストを設定します。
<selenium>
<browser name="Firefox on Linux"
browser="*firefox /usr/lib/firefox/firefox-bin"
host="my.linux.box"
port="4444"
timeout="30000"/>
</selenium>
上の XML 設定は、次の PHP コードに対応します。
class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
public static $browsers = array(
array(
'name' => 'Firefox on Linux',
'browser' => '*firefox /usr/lib/firefox/firefox-bin',
'host' => 'my.linux.box',
'port' => 4444,
'timeout' => 30000
)
);
// ...
}
| Prev | Next |
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertCount()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
Copyright © 2005-2012 Sebastian Bergmann.