CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

How to run test cases in Drupal?

The testing module in Drupal is useful for running automated test cases. It can be used to verify the working state of Drupal before and after any code changes.

This article explains how to run test cases in Drupal.

This applies to:

  • Drupal 7.x

Step (1). Log in to your Drupal-based website as an administrator.

Step (2). Click on the Configuration link which is on top of the page. It will display the Configuration page.

Drupal - Configuration -Development - Testing
Drupal – Configuration -Development – Testing

Step (3). Click on the Testing link which is under the DEVELOPMENT section. It will display the Testing page.

This link will be available only when the Testing module is enabled.

Step (4). The Testing page will display the list of available test cases in test groups.

Drupal - Testing page
Drupal – Testing page
  • By clicking on the arrow mark before the test group, you can expand/collapse the test group.
  • When the test group is expanded, it will display all the available test cases under the test group.
  • You can select each test case by selecting the check-box before the test case.
  • You can also select all the test cases within the test case by selecting the check-box before the test group.

Step (5). Select the test cases you want to execute. Note that, if you select all the test cases, it might take several minutes for all tests to complete.

Drupal - Testing - Expanded test group
Drupal – Testing – Expanded test group

Step (6). Scroll down the page and click on the Run tests button to execute the selected test cases.

Step (7). It will display the Running tests page showing test cases execution progress.

Drupal - Running tests page
Drupal – Running tests page

Step (8). Once running the test cases are completed, it will display the Test result page.

Drupal - Test result page
Drupal – Test result page

Step (9). A message will be displayed next to each test group indicating whether test cases within it are passed, failed, or had an exception.

  • A pass means that the test returned expected results
  • Fail means that the test did not return expected results.
  • An exception normally indicates an error outside of the test.

Step (10). If there were failures or exceptions, the test results will be expanded to show the details, and the tests that had failures or exceptions will be indicated in red or pink rows.

Drupal - Test results
Drupal – Test results

Step (11). You can also re-run failed test cases. On Test result page:

    • Select the Fail item from the Filter combo box in the ACTIONS section.
    • Click on the Run tests button to re-run the failed test case.

You can use these test results to refine your code and tests until all tests pass.

by Code Steps

How to run test cases in Drupal?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top