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:
-
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.
-
In projects that will run on remote computers, create an OnLogError event handler that will change the value of the variable when errors occur.
-
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
-
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:
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.
-
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. -
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:
-
If you use keyword tests
-
-
Open the Test Items page 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.
-
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
-
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. -
Configure the event handler to change the network variable:
-
If you use scripts
Insert the following code into the event handling routine:
-
If you use keyword tests
-
See Also
Controlling Test Execution Flow
About Controlling Test Execution Flow
OnLogError Event
OnNetVarChange Event
Runner.Stop Method
Stop Execution Operation
Parallel Testing
Distributed Testing