How to run a specific phpunit xml testsuite?
Here's the code as if PHPUnit 3.7.13
$ phpunit --configuration config.xml --testsuite Library
$ phpunit --configuration config.xml --testsuite XXX_Form
If you want to run a group of the test suites then you can do this
<testsuites>
<testsuite name="Library">
<directory>library</directory>
</testsuite>
<testsuite name="XXX_Form">
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
<testsuite name="Both">
<directory>library</directory>
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
</testsuites>
Then
$ phpunit --configuration config.xml --testsuite Both
Unfortunately PHPUnit currently does not support nested testsuites like this
<testsuites>
<testsuite name="Both">
<testsuite name="Library">
<directory>library</directory>
</testsuite>
<testsuite name="XXX_Form">
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
</testsuite>
</testsuites>
So if you wanted to run groups of test suites this way you have to have xml configuration duplication!
This is not possible in current versions of PHPUnit as evidenced by these messages in phpunit-user mailing list: http://thread.gmane.org/gmane.comp.php.phpunit.user/1302
But there is an alternative, you can simply pass a path to phpunit.
phpunit library/XXX
This would run all the tests in library/XXX directory
If this is not sufficient for you, another option is to use the @group annotation to divide tests into different categories that could then be run selectively.
As of phpunit 6.1 you can use in the xml config file the attribute defaultTestSuite
, this is like using a default option phpunit --testsuite xxx
and is overriden.