I am trying to run module-provided PhpUnit tests from the CLI.

Following these instructions, so my core/phpunit.xml should be correct now.

Using this command:

cd core
../vendor/bin/phpunit modules/system/src/Tests/Installer/InstallerTranslationTest.php

I get this output:

Class 'modules/system/src/Tests/Installer/InstallerTranslationTest' could not be found in '/****/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php'.

Module-provided tests in e.g. core/modules/system/tests/src/.., are found, and work correctly with the phpunit command. But tests in core/modules/system/src/Tests/.. do not seem to work, or be detected.

(I think I had this problem before, and someone told me what was missing. But I don't remember anything. Time to document this in this Q/A site.)

  • Maybe I need the run-tests.sh for those? If so, then this is not properly documented on drupal.org/node/2116263 ..
    – donquixote
    Commented Jul 6, 2016 at 0:37
  • Ok I think I get it: Those tests are not really "PhpUnit tests". And this is why the phpunit command does not work here. There should be a link from that doc page to where the other kind of tests are explained.
    – donquixote
    Commented Jul 6, 2016 at 0:41

1 Answer 1


Ok, so the solution is

From Drupal root directory:

sudo -u www-data php core/scripts/run-tests.sh --url http://d8.localhost/ --class "Drupal\system\Tests\Installer\InstallerTranslationTest"

Assuming that your site is available under http://d8.localhost, and it is an installed site.

Maybe you want to use --verbose for more output.

Documentation on drupal.org: Running Tests Through command-line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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