Tutorial: Setting Test Step Checkpoint Properties Using Event Handler Code

In this tutorial, you will set the checkpoint properties using event handler code instead of the property value grid in an API test. This is useful if you have input property values generated dynamically during a test run, as you cannot use the Input/Checkpoint Properties tab in the Properties pane to set a property that does not exist before the test run.

In this tutorial, you will be setting the checkpoint properties of a Concatenate Strings step.

Note: We recommend printing this topic or putting the browser window on a second screen before performing this tutorial in a sample API test.

Create a Concatenate Strings

If necessary, from the String Manipulation section of the Toolbox pane, drag a Concatenate Strings step to the canvas.

Back to top

Enter the input properties

  1. In the Properties pane, open the Input/Checkpoints tab .

  2. In the Input/Checkpoints tab, enter the following input properties:

    Prefix Hello (with a space after Hello)
    Suffix World.

Back to top

Create an event handler for the checkpoint.

In order to assist with running checkpoints, UFT One has set a special checkpoint handler that runs after the step to check the step results.

  1. In the Properties pane, select the Events tab .

  2. In the Events tab, in the CodeCheckPointEvent row, click the down arrow and select Create a default handler.

    A separate tab, titled TestUserCode.cs, opens in the document pane, and a section of code is added to this file for the OnCodeCheckPointEvent section.

Back to top

Enable the checkpoint

  1. In the TestUserCode.cs tab, find the TODO: Add your code here... section under the ConcatenateStringsActivity4_OnCodeCheckPointEvent portion of the code.

  2. Delete the //TODO: Add your code here... string.

    Note: Make sure not to delete the brackets on the line above and below the TODO line. These brackets are needed for proper code syntax.

  3. In the same line, enter args. (with the period). (While you type, UFT One displays an autocomplete list, You can use this list if you want to find the args object.)

    After you enter the args. object, UFT One displays another autocomplete list.

  4. From the autocomplete list, select the Checkpoint object:

  5. After the Checkpoint object, type a period (.) character. Another autocomplete list is displayed.
  6. From the autocomplete list, select the RunUICheckpoints object and press ENTER:

  7. After the RunUICheckpoints object, enter =true.

  8. After the true string, type a semicolon (;) character.

    Your event handler code should now look like this:

    args.Checkpoint.RunUICheckpoints=true;
  9. Click Save .

Back to top

Add event handler code for the checkpoint property value

After you enable the checkpoint, you can then instruct UFT One what value to use for the expected value.

  1. Under the line containing the RunUICheckpoints object, enter the args. object (with the period) again.

    After you type the args. object, UFT One displays an autocomplete list.

  2. From the autocomplete list, select the Checkpoint object and press ENTER.

  3. After the Checkpoint object, type a period (.) character. Another autocomplete list is displayed.

  4. From the autocomplete list, select Assert and press ENTER:

  5. After the Assert object, type a period (.) character again. Another autocomplete list is displayed.

  6. From the autocomplete list, select the Equals function and press ENTER:

  7. After the Equals function, add a open parenthesis ( character. Note that the text of the Equals function changes color.

  8. Inside the parenthesis, enter the following string:

    this.ConcatenateStringsActivity4.Prefix+this.ConcatenateStringsActivity4.Suffix),

    Note: Make sure to add the comma after this string to ensure proper function syntax.

    This string provides the actual result of the test step for the checkpoint by setting the value as the Prefix + Suffix properties.

  9. After the previous string, enter the expected string "Hello World."

  10. After the Hello world string, enter a close parenthesis ) character and a semicolon (;) character.

    Your event handler code should now look like this:

    args.Checkpoint.RunUICheckpoints=true;
    args.Checkpoint.Assert.Equals(this.ConcatenateStringsActivity4.Prefix+this.ContatenateStringsActivity4.Suffix,"Hello World.");
  11. Click Save .

Back to top

Run the test

  1. In the toolbar, click the Run button .

  2. In the Run dialog box, click Run. UFT One runs the test, using the property values provided in the Properties pane and your event handler code.

    After your test run is complete, you can see the results to ensure that the event handler code provided the property values correctly:

    Output pane

    In the User Logger section of the output pane, you can see the compilation log for the test run. In this compilation log, there is a step for the checkpoint of the Concatenate Strings step:

    Run results

    In the run results, if you look in the captured data for the step, you can see the input properties used by the test:

Back to top