Custom code steps

Relevant for: API testing only

Add Custom Code steps to your test to create step execution flows using your own special code.

Like other API test activities, Custom Code steps run at the specific point in the test flow, and follow the standard event model:

  1. Beginning with any code entered for the BeforeExecuteStepEvent event;
  2. Followed by the ExecuteEvent event;
  3. And finishing with the AfterExecuteStepEvent event.

However, unlike most API test steps, there is no predetermined step flow.

Example: When you select a standard activity test step, UFT has already preset how to perform the activity, and the only modifications you can make to the test step come by writing special event handler code.

For Custom Code events, the step execution is performed only with the special code you enter.

Custom Code event usage

Because the step execution flow is limited only by the code you use, you can use Custom Code events in a number of ways:

  • Creating unique steps not supported out of the box by UFT API tests.

  • Casting variables or parameters for use in other steps

Each Custom Code step can access properties, parameters, or variables from any test step preceding the step or from a parent activity of the step.

However, do not use Custom Code steps to set step properties or parameters for other steps. Custom Code steps run in their place in the test flow, separate from the other test steps.

Setting a property or parameter value for a test step in a Custom Code step does not affect the property values of the other test steps when they run in the Test Flow.

Back to top

Custom Code step contents

Each Custom Code step is composed of four events:

  • BeforeExecuteStepEvent

  • ExecuteStepEvent

  • AfterExecuteStepEvent

  • CodeCheckpointEvent

Only the ExecuteStepEvent event is mandatory when using a Custom Code step.

Back to top