| Prev | Next |
The attributes of the <phpunit> element can
be used to configure PHPUnit's core functionality.
<phpunit backupGlobals="false"
backupStaticAttributes="true"
bootstrap="/path/to/bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="true"
syntaxCheck="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader">
<!-- ... -->
</phpunit>The XML configuration above corresponds to invoking the TextUI test runner with the following switches:
--no-globals-backup
--static-backup
--bootstrap /path/to/bootstrap.php
--colors
--process-isolation
--stop-on-failure
--no-syntax-check
--loader PHPUnit_Runner_StandardTestSuiteLoader
The convertErrorsToExceptions,
convertNoticesToExceptions, and
convertWarningsToExceptions attributes have no
equivalent TextUI test runner switch.
The <testsuites> element and its
one or more <testsuite> children can be
used to compose a test suite out of test suites and test cases.
<testsuites>
<testsuite name="My Test Suite">
<directory>/path/to/*Test.php files</directory>
<file>/path/to/MyTest.php</file>
</testsuite>
</testsuites>
The <groups> element and its
<include>,
<exclude>, and
<group> children can be used to select
groups of tests from a suite of tests that should (not) be run.
<groups>
<include>
<group>name</group>
</include>
<exclude>
<group>name</group>
</exclude>
</groups>The XML configuration above corresponds to invoking the TextUI test runner with the following switches:
--group name
--exclude-group name
The <filter> element and its children can
be used to configure the blacklist and whitelist for the code coverage
reporting.
<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>
<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>
The XML configuration above corresponds to using the
PHPUnit_Util_Filter class as follows:
PHPUnit_Util_Filter::addDirectoryToFilter(
'/path/to/files', '.php'
);
PHPUnit_Util_Filter::addFileToFilter('/path/to/file');
PHPUnit_Util_Filter::removeDirectoryFromFilter(
'/path/to/files', '.php'
);
PHPUnit_Util_Filter::removeFileFromFilter('/path/to/file');
PHPUnit_Util_Filter::addDirectoryToWhitelist(
'/path/to/files', '.php'
);
PHPUnit_Util_Filter::addFileToWhitelist('/path/to/file');
PHPUnit_Util_Filter::removeDirectoryFromWhitelist(
'/path/to/files', '.php'
);
PHPUnit_Util_Filter::removeFileFromWhitelist('/path/to/file');
The <logging> element and its
<log> children can be used to configure the
logging of the test execution.
<logging>
<log type="coverage-html" target="/tmp/report" charset="UTF-8"
yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-xml" target="/tmp/coverage.xml"/>
<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>The XML configuration above corresponds to invoking the TextUI test runner with the following switches:
--coverage-html /tmp/report
--coverage-xml /tmp/coverage.xml
--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
The charset, yui,
highlight, lowUpperBound,
highLowerBound, and logIncompleteSkipped
attributes have no equivalent TextUI test runner switch.
The <listeners> element and its
<listener> children can be used to attach
additional test listeners to the test execution.
<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>
The XML configuration above corresponds to attaching the
$listener object (see below) to the test execution:
$listener = new MyListener(
array('Sebastian'),
22,
'April',
19.78,
NULL,
new stdClass
);
The <php> element and its children can be
used to configure PHP settings, constants, and global variables.
<php> <ini name="foo" value="bar"/> <const name="foo" value="bar"/> <var name="foo" value="bar"/> </php>
The XML configuration above corresponds to the following PHP code:
ini_set('foo', 'bar');
declare('foo', 'bar');
$GLOBALS['foo'] = 'bar';
The <selenium> element and its
<browser> children can be used to
configure a list of Selenium RC servers.
<selenium>
<browser name="Firefox on Linux"
browser="*firefox /usr/lib/firefox/firefox-bin"
host="my.linux.box"
port="4444"
timeout="30000"/>
</selenium>The XML configuration above corresponds to the following PHP code:
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()assertEqualXMLStructure()assertEquals()assertFalse()assertFileEquals()assertFileExists()assertGreaterThan()assertGreaterThanOrEqual()assertLessThan()assertLessThanOrEqual()assertNull()assertObjectHasAttribute()assertRegExp()assertSame()assertSelectCount()assertSelectEquals()assertSelectRegExp()assertStringEndsWith()assertStringEqualsFile()assertStringStartsWith()assertTag()assertThat()assertTrue()assertType()assertXmlFileEqualsXmlFile()assertXmlStringEqualsXmlFile()assertXmlStringEqualsXmlString()Copyright © 2005-2010 Sebastian Bergmann.