How to execute PHPUnit tests in parallel?


I have some Selenium UI tests which I can run sequentially on local using PHPUnit. They are independent of each other. How can I leverage CircleCI to run them in parallel?


I mean to look at this myself. To investigate this I would look at creating shell scripts that run a portion of the tests, which can be split by file, by a --filter on the tests, by test groups, whatever you like.

I am not sure whether there is a system that can split tests into sets with equal numbers of tests per set, but that would be the ideal. That would allow you to specify a number of sets to match your available parallelism. Of course, splitting tests by time may be better, if your tests vary in the time each takes to execute.

Once you have done that, take a look at the env vars available to see if there’s anything that indicates the parallelism position they occupy. Maybe CIRCLE_NODE_INDEX is what you need? It might be in the docs. From there, you can use this to activate your shell scripts with the appropriate filters you have set up.


I was referring to Run phpunit tests in parallel

@rose Does the following still holds true? We’d like to have more control on the test splitter with phpunit.

As far as I can tell, circleci tests glob and circleci tests split are incompatible with PHPUnit, as it is not possible to pass a list of filenames to phpunit . The only close match— --filter , as you identified—only accepts a REGEX match of classnames, which is not something that our native test-splitter can output.

Re-opening this in case anyone has had a different experience using PHPUnit and circleci tests split . If we can verify that it’s not currently possible, from there we can try to get some work done on our test-splitter to mitigate this issue, and also for the timebeing update our documentation to make it explicit that not all test-runners are compatible.


Yes, I guessed you were looking to use the CircleCI test splitter. I’ve never used that, but as I say, I think you can do it yourself, using env vars available to you.