Running code under the AUT testing tool context

When the Custom Server is running in the testing tool context, there is no direct access to the control, which is in a different run-time process. To access the control directly, run part of the code in the Application under test context. This is done using assistant classes.

Note: Running in the testing tool context is supported only for .NET Framework versions, and required only in versions 26.1 and earlier, and only if the Custom Server needs to listen to Windows events.

In versions 26.3 and later, the Custom Server can listen to Windows events in the AUT context as well.

To launch code from the testing tool context that runs under the Application under test context, implement an assistant class that inherits from CustomAssistantBase. To create an instance of an assistant class, call CreateRemoteObject. Before using the object, attach it to the control with SetTargetControl.

After SetTargetControl is called, you can call methods of the assistant in one of the following ways:

  • If the method can run in any thread of the Application under test process, read and set control values and call control methods with the simple obj.Member syntax:

    int i = oMyAssistant.Add(1,2); 
    
  • If the method must run in the control's thread, use the InvokeAssistant method:

    int i = (int)InvokeAssistant(oMyAssistant, "Add", 1, 2); 
    
  • Tip: You can use the EventListenerBase, which is an assistant class that supports listening to control events.

For more information, see Reviewing commonly-used API calls.