I follow the ZF2 agreement on storing tests in modules, and everything works fine when tests are run from each module. What I would like to do is have phpunit.xml at the root level, which calls the individual unit tests and combines them to create code coverage data and other metrics.
The problem is that each individual test suite is loaded into the phpunit.xml module files. The only way I know is to configure the download in each phpunit.xml file, which, obviously, is not selected when running tests from root, as individual xml files are ignored.
So my question is: is there a way for the phpunit.xml file at the root level to read individual phpunit.xml and bootstrap files from modules, something like inheriting the phpunit configuration if you do this? I could go the way of writing this in a Phing or CI script, but I would like it to be quick and dirty during development, and this solution still did not generate a code summary report.
Basically, I want something like this, but instead of running tests, I want it to run separate phpunit.xml files in each module. Is it possible?
<?xml version="1.0" encoding="UTF-8"?> <phpunit> <testsuites> <testsuite name="Site Tests"> <directory>./module/Application/test/ApplicationTest</directory> <directory>./module/User/test/UserTest</directory> </testsuite> </testsuites> </phpunit>
Update
The goal is to have code metrics generated by PHPUnit that give a project overview, rather than a modular concrete overview. I appreciate that the scripts in the answers will run unit tests for each module, but that is not what I am looking for. I understand that this may be a limitation regarding PHPUnit. I will review this over the next few days and try to find a solution, as it looks like it would be useful in many projects that deal with custom modules.
Update 2
Robert Basic came up with a script that creates a directory structure with module reports inside, and it works great, but it would be nice to have it in PHPUnit with the corresponding metric reports.
https://gist.github.com/robertbasic/5329789