Skip to main content
Last Reviewed: 2022-12-13

Write a New Test

In step six of the Build Tools guide, learn how to use the pre-configured site tests, or customize your own.


The Pantheon example projects include some basic tests to validate basic capabilities of the given framework. You can customize these tests and add more to fit your project needs. Drupal uses Behat and the WordPress example uses WordHat.

The behat-pantheon.yml file sets the path for a project's collection of Behat tests. Any file with a .feature suffix in a listed directory will be executed as part of the standard test run on CircleCI.

There are also visual regression tests using BackstopJS that run when composer.lock has changed, but composer.json has not. The scripts are a part of the template repositories: example-wordpress-composer and example-drops-8-composer

Extending the Example Test Suite

The following is an example of how to increase test coverage for your project by validating site configuration. This test will confirm the site slogan implemented in a previous lesson has been applied to the associated Multidev environment:

  1. Pull commits added to the slogan branch in the previous lesson:
  1. Create the directory tests/site-features and add a new file called slogan.feature that contains the following:

It's a relatively simple task to add new tests that exercise your site through its interface. The following example demonstrates testing that an administrator can create with a new page on the site.

  1. Create a new file called content-ui.feature within the tests/site-features directory containing:

By following this pattern, you can add similar tests to confirm that the most important features of your site remain functional. To save time on test runs, remove the example tests that cover basic Drupal features, and only run tests on your core functionality.

  1. Commit your new files to the slogan branch and push to GitHub for peer review:

Behat Test Artifacts

If you create content through a Behat And I press phrase, it usually will not be automatically deleted when your test run is complete. Tests that execute custom or non-standard forms may create content that Behat does not know how to remove automatically, and tests that are validated by the existence of this content may show false positives on multiple runs, since the content was created previously.

If you write these sorts of tests, consider writing tests to delete the content they create, to avoid many copies of the same test content from piling up in your Multidev environment.