Drupal-project: How to run PHPunit tests

Created on 15 Sep 2016  路  6Comments  路  Source: drupal-composer/drupal-project

I try to run from the root ./vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist ./web/modules/custom however I get a PHP Fatal error: Class 'Drupal\Tests\BrowserTestBase' not found error (even-though it's properly declared).

I tried to execute it also from inside the web, but it doesn't work. What is the proper way to run those tests, so I could also add it to Travis?

Most helpful comment

./vendor/bin/phpunit -c ./web/core ./web/modules/custom/ for custom modules.

All 6 comments

./vendor/bin/phpunit -c ./web/core ./web/modules/contrib/ should work. phpunit.xml.dist is to test the project template itself. Not Drupal core and modules.

./vendor/bin/phpunit -c ./web/core ./web/modules/custom/ for custom modules.

oh yeah, I tried with that one as-well. I've probably done something wrong, I'll re-check. Closing for now. Thanks :)

Great, it's working

Sorry to raise this issue again. But, to me, having phpunit.xml.dist in template folder is still confusing. May be there should be some comments on how to run phpunit tests and on what level? Or renaming the file would work probably. But by default no one will specify the configuration file which will be exactly the template level phpunit.xml file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

9034725985 picture 9034725985  路  6Comments

criley picture criley  路  6Comments

chanster picture chanster  路  5Comments

gkapoor1 picture gkapoor1  路  3Comments

andeersg picture andeersg  路  5Comments