Warning message

Documentation is currently being migrated into the new system. Some pages might be temporarily missing, and some guides might appear empty. Thank you for your patience while we are improving Drupal.org documentation.


SimpleTest is Drupal's custom testing framework. During the Drupal 7 development cycle SimpleTest has become an integral part of the workflow, and it has been moved into core as the Testing module. It has significantly enhanced the way core is developed and made it possible to make major API enhancements with confidence. In Drupal 6, it was known as the SimpleTest module and it lives in the contributed repository.

Tests in Drupal core are usually one of three types:

  • Functional tests are most common. They create a fresh database installation and specifically create data for the test in the database and then make assertions based on expected results.
  • Unit tests work without a database installation in the backend and are useful for isolated functions that don't make assumptions about the larger system.
  • Upgrade tests use a database dump from an earlier version of Drupal and import that to run update.php and then check assertions.

Simpletest Testing overview (Drupal 7)

Testing in Drupal 7 focuses on functional testing instead of unit testing.

Testing module

The Testing module (Drupal 7.x and beyond) or SimpleTest module (Drupal 6.x) provides a framework for running automated unit and

Simpletest Testing tutorial (Drupal 7)

This tutorial will take you through the basics of testing in Drupal 7.

Unit Testing with SimpleTest

Note: The code for this tutorial is maintained in the Examples for Developers module. This means:

Organizing your test cases

Here are some suggestions for organizing your test cases. It is best to put your test cases in files with certain names in certain locations

Selenium testing

Selenium is a tool which automates browser testing, and so can be used to test your Drupal website.

Testing setup and configuration

SimpleTest has a few non-default requirements.

Writing upgrade path tests

This document explains how to write tests for the Drupal core upgrade path.

Run tests

Once you have completed the Setup and configuration (enabled the Testing module) you are ready to run some tests.

Running tests through command-line

Command-line test execution - Linux

Troubleshooting tests

Use the new debug()

SimpleTest upload tests hanging

SimpleTests involving file uploading of any kind result in the test never finishing on Mac OS X covering Leopard and possibly other versions

SimpleTest [Browser] on Vista

The Symptom

Improving SimpleTest performance

Performance: improving the speed of SimpleTest during development.

Testing Reference

The following resources provide some additional information on testing with Drupal. Please also read the sub-pages with more details.

API functions

The internal browser


Up to date documentation or additions may be found at the api.drupal.org reference site (not necessarily formatted for browsing).

Why test

You should write SimpleTests for your modules to ensure quality. SimpleTests allow you, the developer, to quickly test your module after

Core tests

Drupal core now comes with numerous tests for functionality (in the region of 50-70% code coverage as of June 2008).

Hidden modules and themes

Sometimes, hooks we want to test are not used in any of the core modules, or core modules do not cover all the use cases of these hooks.

Comprehensive example

Now it's time to try a browser test. We don't have to change too much in our class, because DrupalWebTestCase class contains tools for both

Miscellaneous SimpleTest tips

This is a list of some general tips for writing tests, feel free to pitch in and add your own!