In my application, I have the phpunit tests next to the source code. So in all maps next to let’s say DoSometing.class.php I have a DoSomethingTest.class.php.
I want to configure phpunit.xml to test all these *Test.class.php files.
How do I do that in phpunit.xml?
I have something like this at the moment:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="true"
syntaxCheck="false">
<testsuites>
<testsuite name="My Test Suite">
<directory>./*Test.class.php</directory>
</testsuite>
</testsuites>
<groups />
<filter />
<logging />
<listeners />
</phpunit>
We use a similar structure, only our test files end with the extension .TEST, or .QTEST, .JTEST based on the testing framework since we have JavaScript and other embedded code as well that needs testing. As such, we use the suffix option on the directory node as shown below.
For the PHP Unit tests (*.TEST) we use the following PHPUNIT.xml (this is edited for size)