I am starting to write our tests with PHPUnit on Drupal 8, and I am not sure about the best practices with the phpunit.xml.dist file. We separates the custom and the contrib modules using two directories in the /modules directory - /modules/custom and modules/contrib. The original phpunit.xml.dist file contains the following line <directory>../modules/*/tests/src/Unit</directory> so I had to add the <directory>../modules/*/*/tests/src/Unit</directory> directory.

I have another issue with sub-modules, our current structure is /modules/custom/main_custom_module/modules/sub_module, so I had to add another directory to the file (<directory>../modules/*/*/modules/*/tests/src/Unit</directory>).

What is the best practice when it comes to overriding the phpunit.xml.dist file? should I remove the file from VC (e.g. git,svn..)?

  • <directory>../modules/*/*/tests/src/Unit</directory> please file a core patch for this. – user49 Jun 21 '15 at 17:26
  • That's a bug, see drupal.org/node/2499239. – Berdir Jun 21 '15 at 18:05

The right thing to do is to not add it to the core phpunit.xml.dist file. You have your own code, so you want to test that. The idea that core also tests contrib / custom code is not the right thing to do, IMHO

  • As far as I understand your opinion is the opposite to D8 and PHPUnit's guidelines – rreiss Jun 21 '15 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.