Event Handlers for API test steps

Relevant for: API testing only

An event handler is a specific occurrence of a defined code process triggered at a specific point in the overall test flow. Use event handlers in your API tests to change or extend your testing.

Event handler usage

When you run a test of your application's API, or when you run the application itself, each business process is executed as defined in your application's code.

These processes are each represented by your test's steps. To extend your application and test functionality, add events to your application code, and event handlers to your test.


You might add an event handler after compiling a Web service call response to do one of the following:

  • Set security for the Web service response data
  • Add attachments to the Web service call response

Back to top

Available resources in event handlers

Event handlers are designed to be run at a specific point in the application/test workflow. The objects, methods, and properties available in a given event handler are limited to the context of where the event occurs in the application or test workflow.

This means that while working in an event handler, you cannot access the process's or step's output properties, as these properties are part of an application or test that hasn't yet run.

If you use an event handler out of the context in which it was designed, the properties and methods the test will try to use are not accessible.


To set the request properties of one step based on the response properties of a previous step, create code in an event handler called BeforeExecuteStep. There, enter the property values you would like your test to use.

Available properties and methods are limited to the objects contained in the context of the step's flow, and the event handler located immediately after the step.

These include the output or response properties available in the previous step, and the input or request properties of the current step.

Back to top