Modularizing Tests — Reusing Test Steps

Ghost Inspector gives you the ability to “modularize” your tests — meaning that you can take a set of steps that are going to be repeated across various tests and turn them into an importable module. You can import the steps of one test into another by adding an “Import steps from test” step in the test editor. This allows you to segment out certain repeated operations and easily reuse them.

For instance, if most of your tests require a login sequence at the beginning, you could create a “Login” test and insert it as the first step of those tests. This saves you from having to repeat the logins steps across multiple tests. Instead, you’ll have them stored in one single test which acts as an importable test module. This makes step updates and test maintenance much easier. Changes can be made to a single test module and the updates will be immediately reflected in all the tests that import that module.

Import test steps in test editor

You can import multiple tests within a single test. You can also nest tests multiple levels deep. For instance, “Test A” could include “Test B” as its first step, and “Test B” could include “Test C” as it’s first step. You can go up to 10 levels deep with nesting.

To help identify tests that are only meant to be used as imported steps, you can enable the "Import Only" option in Settings > Modularization. Enabling this option will:

  • Prevent the test from being executed (directly or as part of the suite)
  • Disable the passing/failing status and display
    Import Only
  • Remove all previous test results
  • Hide parts of the UI that are no longer applicable

If you wish to see everywhere that a test is imported, the list can be found on the test detail view for tests that are marked as "Import Only". If that option is not enabled, you can still see the list under Settings > Modularization in the test. There is a section called “Importing Tests”. Clicking the “Fetch” button will load a complete list of tests that import the current test across your entire organization.

Test Modularization Settings

Note #1: When importing a test into another test, the system is simply including its steps prior to execution. It is not executing the imported test within a separate scope or browser, nor does it navigate to the start URL of the included test.
Note #2: You must have at least one other test in your account for the “Import steps from test” step action to appear.