Information in this topic applies to desktop and web applications. |
With TestComplete, you can create distributed tests that run test projects on different test machines concurrently. By default, the projects work independently and do not exchange information about errors that occur in them. So, for instance, the master project gets information about the slave project’s results only when the test run is over. You may want to change this default behavior and perform specific actions when an error occurs in one of these projects. For example, you may need to stop the entire test run if an error occurs in one of the slave projects. This topic explains how you can do this.
General Approach
By default, the master project receives information about errors that occurred in slave 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. To detect the changes of network suite variables, use the OnNetVarChange
event. The entire procedure includes the following steps:
-
Create a network variable that will be shared between all distributed tests.
-
In the slave project, 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 master and slave projects.
Preparing the Master Project
To prepare the master project, follow these steps:
-
Open the project properties and select Playback on the list on the left of the page. Disable the Stop on error and Error dialog options. Otherwise, TestComplete stops the entire test run right after the first error or exception occurs.
-
Open the Variables page of the Network Suite Editor and create a network variable there. We will use this variable as an error semaphore for all the projects that participate in distributed testing:
Note: This variable will be available for the slave projects when the distributed testing starts, so you do not have to create it in each slave 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, do the following:
-
-
Open the Test Items page of the Project Editor 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: Also, you can specify NetworkSuite as a test item. In this case, TestComplete runs jobs that are specified in the Jobs Editor. However, if an error occurs, it will stop the NetworkSuite test item. It means that the subsequent jobs will not be run. -
Change the Stop on Error properties of the project suite’s and project’s test items to customize the further behavior of the test engine. To learn more about it, see Stopping Tests on Errors and Exceptions - Overview.
Preparing Slave Projects
Follow these steps:
-
Create an event 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. This handler allows you to catch the moment when an error occurs. -
In the event handler, create the test commands that will change the network variable:
-
If you use scripts, insert the following code into the event handling routine:
-
If you use keyword tests, do the following:
-
See Also
Controlling Test Execution Flow
Stopping Tests on Errors and Exceptions - Overview
OnLogError Event
OnNetVarChange Event
Runner.Stop Method
Stop Execution Operation
Parallel Testing
Distributed Testing