I use phpunit's testsuites feature to organize my tests. I do so to have the ability to run tests in parallel later on.
This is relatively straight forward for different directories. So i could split up testsuites by bundle for example.
<testsuite name="bundle-one">
<directory>tests/BundleOne</directory>
</testsuite>
<testsuite name="bundle-two">
<directory>tests/BundleTwo</directory>
</testsuite>
<testsuite name="bundle-three">
<directory>tests/BundleThree</directory>
</testsuite>
But now i have one single directory (services) which contains dozens of sub-folders. I could manually make several testsuites our of this folder. But this would be a weak solution in my opinions. Because the testsuites could break easily if i mention every sub-folder in them and the folders get renamed or removed.
My idea was to use some kind of regular expression to select a range of sub-folders to include in one testsuite and another range of folders for another testsuite.
<testsuite name="services-AM">
<directory>tests/services/{A-M}</directory>
</testsuite>
<testsuite name="services-NZ">
<directory>tests/services/{A-M}</directory>
</testsuite>
I could not find any documentation on my idea. Does anybody might have an idea for this ? :-)
Im not sure if there's a way to do this "on-the-fly" but you could automate the process of creating these bundles from reg-ex:
In composer.json:
"scripts": {
"make-phpunit-bundles": "php path/to/myscript.php"
},
before running tests:
php composer.phar make-phpunit-bundles
myscript.php:
//Iterate/scan your directories, build and write the phpunit.xml file
//based on the regular expressions you want