Stop Tests on Hosts When an Error Occurs on One of Them

Applies to TestComplete 15.46, last modified on January 09, 2023
This section describes how to handle errors on remote hosts in distributed testing. The Network Suite functionality used for the distributed testing in TestComplete will be deprecated in one of the future releases. We do not recommend that you use it. As an alternative, we recommend that you use a CI/CD system to manage distributed tests. To learn more, see Migrating Distributed Tests to CI/CD Systems.

With TestComplete, you can create distributed tests that run test projects on several test machines concurrently. By default, the projects work independently and do not exchange information about errors that occur in them. The master project (the one that controls the runs of other projects) gets information about the test results only when the test run is over. You may want to change this default behavior to handle errors that occur in these projects. For example, you may want to stop the test run if an error occurs in one of the projects.

General Approach

By default, the master project receives information about errors that occurred in other projects only after the distributed test stops. To change this behavior:

  1. Create a network variable and use it as a marker that notifies about an error. The projects that took part in the distributed test share network suite variables. When you change a network suite variable in one of the projects, the others will get notification about this and can handle this situation in the desired manner.

  2. In projects that will run on remote computers, create an OnLogError event handler that will change the value of the variable when errors occur.

  3. In the master project, create an OnNetVarChange event handler that will stop the distributed tests when the network variable is changed.

Below, you can find detailed descriptions of how to configure the projects.

1. Prepare the Master Project
  1. Open the Variables page of the Network Suite and create a network variable. We will use this variable as an error semaphore for all the projects that participate in distributed testing:

    Creating a network variable

    This variable will be available for all participating projects when the distributed testing starts, so you do not have to create it in each project.

  2. Create an event handler for the OnNetVarChange event. For more information on how to do this, see Creating Event Handlers for TestComplete Events. This event occurs every time when a network variable changes.

  3. In the event handler, create test commands that verify what variable was changed and perform the desired actions. To determine the variable that was changed, use the event handler’s VarName parameter (it specifies the name of the changed variable).

    • If you use scripts

      Insert the following code into the event handling routine:

      Show Code

    • If you use keyword tests

      Show Instructions

  4. Open the Execution Plan editor of your master project and specify the desired jobs as separate test items. In this case, TestComplete will continue test run with the next job if the current fails.

    Note: You can also specify Network Suite as a test item. In this case, TestComplete runs jobs that are specified in the Jobs project collection. However, if an error occurs, it will stop the Network Suite test item. It means that the subsequent jobs will not be run.

  5. Set the On error property of the master project’s test items to customize the further behavior of the test engine. To learn more about it, see About Controlling Test Execution Flow.

2. Prepare Remote Projects
  1. In projects that will run on remote computers, create a handler for the OnLogError event. See Creating Event Handlers for TestComplete Events. The OnLogError event occurs every time TestComplete posts an error message to the test log. Use this handler to catch the moment when an error occurs.

  2. Configure the event handler to change the network variable:

    • If you use scripts

      Insert the following code into the event handling routine:

      Show Code

    • If you use keyword tests

      Show Instructions

See Also

Controlling Test Execution Flow
About Controlling Test Execution Flow
OnLogError Event
OnNetVarChange Event
Stop Method
Stop Execution Operation
Parallel Testing
Distributed Testing

Highlight search results