3
votes

I have a project that is broken down into the following:

ProjectName/
  ModuleOne/
  ModuleTwo/

each module has a phpunit.xml and a test directory. Each module also has their own composer.json and so on and so forth, allowing me to easily package this as one library or allow you to get specific modules based on your needs.

The issue I have is that since each module has its own test folder with a phpunit.xml file, I need to create another phpunit.xml at the root of the project that runs each modules tests. I thought I could do this via:

<testsuites>
  <testsuite name="ModuleOne">
    <directory>ModuleOne/tests/</directory>
  </testsuite>
  <testsuite name="Moduletwo">
    <directory>Moduletwo/tests/</directory>
  </testsuite>
</testsuites>

But when I run phpunit from the root directory I get a message saying no tests were run. Why? I specified the test suite name and the directory of where the tests live...

Is there something I am missing?

1
each module have a proper classloader/bootstrap files? Have you specified it in the phpunit files? I suggest you to manage it via an ANT script: you can describe all operation you need in a proper build.xml files. Let me know if you need more info. Hope this helpMatteo
Each module has a tests/ directory and inside each there is a phpunit.xml and a bootstrap.php for those tests.TheWebs

1 Answers

0
votes

Unfortunately PHPUnit automatically applies phpunit.xml or phpunit.xml.dist only in the current working directory (see documentation for --configuration here).

There may be a way to set PHPUnit options dynamically from the test itself, or you can try using custom test suite loader or result printer. But I'd suggest just running PHPUnit two times and then combining the results if needed.