Monday, March 12, 2007

Adding Logic to the Test Script

Adding Logic to the Test Script
In this exercise you will program decision-making logic into the test script using
an if/else statement. This enables the test to:
• check that the total is equal to the number of tickets ordered multiplied by the
price per ticket
• report whether the total is correct or incorrect
1 Place the cursor below the last edit_get_text statement in the lesson7
script.
2 Add the following statements to the test script exactly as they appear
below. Note that the tabs or spaces at the beginning of the second and
fourth lines are optional.
if (tickets*price == total)
tl_step ("total", 0, "Total is correct.");
else
tl_step ("total", 1, "Total is incorrect.");
In plain English these statements mean: "If tickets multiplied by price equals
total, report that the total is correct, otherwise (else) report that the total is
incorrect."
3 Add a comment to describe what this section of the script will do.
Place the cursor above the if statement you added in the previous step. Choose
Edit > Comment. After the # sign, type: check that the total ticket price is
calculated correctly.
4 Save the test.
Choose File > Save or click the Save button.