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
Confidence
Drupal's use of PHPUnit and testing best practices are well established.
Drupalize.Me resources
Drupal 7
External resources
-
PHPUnit in Drupal 8 (Drupal.org)
- This is the official documentation on Drupal.org around the PHPUnit testing framework that is included in the core software. 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 for Developers project (drupal.org)
- The Examples module contains sub-modules (phpunit_example, simpletest_example) that illustrate how to write various types of tests. In addition most (if not all) of the other example sub-modules 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.
-
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.
-
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.