Create and run a simple API test

This lesson teaches how to build a basic simple API test in UFT One.

Create an API test and basic steps

Create a new API test.

  1. In UFT One, click New toolbar button down arrow and select New Test.

  2. In the New Test dialog box:

    1. Select API Test.
    2. In the Name field, enter Basic.
    3. Leave the default location, and leave the Solution Name field blank.
    4. Click Create to create your new test.

    The test is shown in the Solution Explorer, under the Solution Untitled node, which is the default name when no solution is specified. The empty test flow is also shown in the Document pane, in the Basic tab.

Back to top

Add basic steps

Add basic steps to write a string to the log, and then replace one word in the string:

  1. Add a step to test the Concatenate Strings activity:

    1. Display the Toolbox pane, and browse to the String Manipulation > Concatenate Strings activity.
    2. Drag the Concatenate Strings activity to the canvas, inside the Test Flow box.

  2. In the Properties pane on the right, click the Input/Checkpoints tab , and define the properties as follows:

    Input area

    Enter the following values:

    • Prefix. Enter Hello , including the space after the word.
    • Suffix. Enter world., including the period.
    Checkpoints area

    Do the following:

    • Select the Result Validate option.
    • In the Expected Value column, select =, and then enter Hello world., including the period.
  3. Add another step to replace the string you just defined.

    From the Toolbox pane, drag the String Manipulation > Replace String activity to the canvas, below the Concatenate String step.

  4. With the Replace String step selected in the canvas, define the properties as follows in the Properties pane on the right:

    General tab

    Rename the step from Replace String to Change Text.

    Enter the Change Text in the Name field, and press ENTER.

    Input/Checkpoints tab

    In the Input area, enter the following values:

    • Source string. Hello world.
    • Search string. Hello
    • Replace string. Goodbye
    • Case-sensitive. false

    In the Checkpoints area:

    • Select the Result Validate option.
    • In the Expected Value column, select =, and then enter Goodbye world., including the period.
  5. Save your test, and continue with Run the test and analyze the results.

Back to top

Run the test and analyze the results

Run your API test and view the results:

  1. Click the Run toolbar button.

  2. In the Run dialog, accept the default values, and click Run to start running the test.

  3. As your test runs, watch the log being compiled in the Output pane below, as UFT One performs your steps.

  4. When the test run completes and the run results are displayed, navigate down in the Test flow area and click the Concatenate Strings and Change Text steps.

    Note how UFT One performed and recorded the steps as you'd configured them.

    For example:

Back to top

Next steps: