Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 1.7 KB

README.md

File metadata and controls

43 lines (36 loc) · 1.7 KB

Drush's test suite is based on PHPUnit. In order to maintain high quality, our tests are run on every push by Travis

Usage

  1. Install PHPUnit

    php composer.phar install --dev
    composer install --dev
  2. Review the configuration settings in phpunit.xml.dist. If customization is needed, copy to phpunit.xml and edit away.

  3. Run unit tests:

    $ cd tests
    $ php ../vendor/phpunit/phpunit/phpunit.php .

Advanced usage

  • Run only tests matching a regex: phpunit --filter=testVersionString
  • Skip slow tests (usually those with network usage): phpunit --exclude-group slow
  • XML results: phpunit --filter=testVersionString --log-junit results.xml
  • Use an alternate version of Drupal: UNISH_DRUPAL_MAJOR_VERSION=8 phpunit ...

Reuse by Drush Commandfiles

Drush commandfiles are encouraged to ship with PHPUnit test cases that extend Drush_UnitTestCase and Drush_CommandTestCase. In order to run the tests, you have to point to the drush_testcase.inc file such as phpunit --bootstrap=/path/to/drush/tests/drush_testcase.inc. The devel project does exactly this - http://drupalcode.org/project/devel.git/blob/refs/heads/8.x-1.x:/develDrushTest.php

Cache

In order to speed up test runs, Unish (the drush testing class) caches built Drupal sites and restores them as requested by tests. Once in while, you might need to clear this cache by deleting the /drush-cache directory.