Test classes diagram

The Site Test module is an extension of the Drupal core SimpleTest module for running site-specific tests in-place on an active Drupal installation. Unlike the core SimpleTest module, which creates a new Drupal installation with a blank database for each test run, SiteTest allows to clone existing database for each test and run it with real-world data and configuration.

SiteTest allows for each test to run in 3 modes:

  • Site - use current database tables.
  • Clone - create copy of site tables.
  • Core - create new tables for blank Drupal installation (core SimpleTest module implementation).


We've observed 'Core' mode tests that ran in 40s running in 1-2 seconds in 'Site' mode.
Tests in 'Clone' mode run 5-10 seconds longer than tests in 'Site' mode, but it depends on number and size of tables. This performance increase is related to the fact that, unlike 'Core'-mode, no module installation performed for each test run.

Why not SimpleTest contrib module

The SimpleTest contrib module replaces the core SimpleTest module making it difficult to retrofit into existing environment without the risk of breaking existing tests. Site Test takes a different approach in that it sits as a layer between the core SimpleTest module and your site tests. You still can run standard SimpleTest tests using core SimpleTest module and run Site Test tests independently.


This module requires the following modules:

  • Simpletest (core)

Recommended modules

Writing your first test

  1. Enable the site_test module on your site.
  2. In a custom module or feature, create a new folder called 'tests'.
  3. Copy the file 'site_test.example.test' from the site_test/examples folder into your modules test folder and rename to suit the objective of your test.
  4. Change the getInfo values to reflect the nature of your test.
  5. In your modules .info file add the test file using: files[] = tests/site_test.example.test
  6. Clear cache and visit admin/config/development/testing/site_test to run your test.

Test modes

Within the getInfo() test definition of your test there is a mode property which
allows you to set whether your test runs on the current instance, a cloned
instance or a fresh Drupal installation.

  • Site mode (site)
    Run the test directly on your site, with the current database and files. This
    mode is extremely fast and is best for most tests however if you're precious
    about your database you will need to clean up after yourself or ensure your
    test doesn't add any unwanted data.
  • Clone mode (clone)
    For each test run, the system will clone the current site as a whole into
    prefixed tables on the same database and run the tests on a sandboxed version
    with the exact same data and configuration. This method is slow for large
    databases but generally much faster than the core method and will not affect
    your database or site configuration.
  • Core mode (core)
    For each test run, the system will build a fresh installation of Drupal in
    prefixed tables. This is the way in which the core SimpleTest module runs and
    all site configuration (including enabling modules) must be done individually
    for each test. This is the slowest and most cumbersome mode and doesn't allow
    for doing complex business logic test case that depends on replicating
    complex site conditions.

Project Information