Drupal ships with a wide variety of unit and functional tests. It is important to understand the main differences between these types of tests, as well as why they are important to improve the overall quality of your application. Drupal also includes a couple of methods for running these test suites.

Example tasks

  • Run the tests included in Drupal core
  • Understand the differences between the different types of tests included in Drupal
  • Write custom tests to minimize bugs in your own application


While the transition from SimpleTest to PHPUnit is well underway, there may be some emerging best practices in this area. This is especially true in regards to support for JavaScript-based functional tests because the PhantomJS project is no longer being supported.

Drupalize.Me resources

Being able to execute, and step debug, Drupal's test using the PhpStorm UI makes it easier and more efficient to write tests for your projects. Learn how to configure PhpStorm to run Drupal's PHPUnit tests inside of a DDEV-Local environment using docker-compose and a remote PHP CLI Interpreter. This setup will work for both Drupal core and your custom code.

Drupal 7

More Guides

We have guides on many Drupal skills and topics.

Explore guides

External resources

  • PHPUnit in Drupal 8 (drupal.org)
    • This is the official documentation on drupal.org around the PHPUnit testing framework that has been added to core in Drupal 8. It provides a great landing page for learning more about the variety of tests that ship with Drupal core and how to get started writing your own tests.
  • Examples project (drupal.org)
    • The Examples module contains submodules (phpunit_example, simpletest_example) that illustrate how to write various types of tests. In addition most (if not all) of the other example submodules that demonstrate additional types of functionality contain tests of their own as well. This is a great source of well-commented code covering a variety of testing cases.
  • Converting D7 SimpleTests to Drupal 8 (drupal.org)
    • This documentation can help you learn how to convert your existing Drupal 7 SimpleTests into Drupal 8's PHPUnit tests.
  • Simplytest.me Evaluate Drupal projects online (simplytest.me)
    • The community-provided simplytest.me service allows you to create an environment with any combination of contributed module, theme, or patch and run the test suite against it. It's a really handy way to run core's test suite if you don't have a local installation handy.
  • Testing your site with the Drupal Extension to Behat and Mink (behat-drupal-extension.readthedocs.io)
    • Another commonly used option for testing in the Drupal world is Behat. While not part of Drupal core (yet -- there's an open issue to add it), a lot of Drupal developers use it for the integration and functional testing of their specific applications. There are also several session from previous DrupalCons that cover Behat testing.
  • Learn to test like a grumpy programmer (grumpy-learning.com)
    • This site was created by well-respected PHP developer Chris Hartjes. His e-books contain a lot of higher-level, and practical, advice about why you should be writing tests alongside your code.