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.
-
In UFT One, click New toolbar button down arrow and select New Test.
-
In the New Test dialog box:
- Select API Test.
- In the Name field, enter Basic.
- Leave the default location, and leave the Solution Name field blank.
- 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.
Add basic steps
Add basic steps to write a string to the log, and then replace one word in the string:
-
Add a step to test the Concatenate Strings activity:
- Display the Toolbox pane, and browse to the String Manipulation > Concatenate Strings activity.
- Drag the Concatenate Strings activity to the canvas, inside the Test Flow box.
-
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.
-
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.
-
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.
- Save your test, and continue with Run the test and analyze the results.
Run the test and analyze the results
Run your API test and view the results:
-
Click the Run toolbar button.
-
In the Run dialog, accept the default values, and click Run to start running the test.
-
As your test runs, watch the log being compiled in the Output pane below, as UFT One performs your steps.
-
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:
Next steps: