In this exercise you expand the functionality of your new action by having it derive
some values and return them to the calling entity.
If you haven't done so already,
complete the exercise Encapsulating action lines
You will be expanding upon the work you did there.
We will extend the action choose rental location and dates by
having it return two values to the calling entity: the duration, in days, of the
rental period, and the total price for the rental. In order to allow it to calculate
the total price, we will also add an argument so that we can supply it with the
daily rental rate.
In TestArchitect, go to the information
subtab of the choose rental location and dates action and add
three new arguments: daily rate, price
and duration. Click Apply.
Before we complete our revision of choose rental location and
dates , let's update our call to it in the test module.
Return to test case TC 04 (call the encapsulated action) in
your test module, My streamlining. Insert a few spaces
under the TEST CASE heading, and add the following two variable
Note: These variables will be used to accept the values returned from the action
call: d will hold the car rental duration, and
p will hold the total rental price.
Next, select the leftmost cell of the choose rental location and
dates action line (the call that holds the action name), press
function key F2, and then press
The effect of this sequence is to resubmit the action name to the
editor, causing the argument header list to be refreshed. Because you earlier
(Step 1) added new arguments to the action, their names
now appear in the header line.
Under the argument headers daily rate,
price and duration, enter the
values 30, >>p and >>d,
that the double chevrons (>>) preceding the p and
d are optional, and have no functional effect. The double
chevron is actually just a useful reminder to anyone reading the file that
associated argument is one that effectively returns a
At this point, your test case should look like this:
So the value for daily rate,
which is 30 dollars per day, is simply being passed into the action. By
contrast, the variables d and p pass in
nothing, but are instead expected to hold values returned from the action.
Tip: It's interesting to note that, from the standpoint of the
action being called, the values passed in the
duration and price arguments
are no different than, say, the rental city argument.
That is, in each case they are simply passing in strings ( "d",
"p", and "Miami", respectively). The fact that
d and p have been declared as
local variables has no effect on the action call. Instead, we are using the
duration and price arguments
to inform the called action that the names of the variables it should
write to are d and
Below the action call, add the following report action:
This will allow us to confirm that the proper values have been returned
from our action call.
Now let's finish creating the logic for the action.
Open the choose rental location and dates action, and click
on the Editor subtab.
Append the following action lines to the end of the file:
Let's look at these lines in order:
Now return your test module My streamlining, by clicking
on its tab or double-clicking its node in the TestArchitect explorer tree.
Ensure that the Car Rental application is running and displaying the
Select Date and Location window. Skip the next two steps if
If you have not already done so, start
the Car Rental application by selecting .
The login window appears.
Navigate to the application window Car Rental-Select Date and
Location by clicking Login,then
Execute test case TC 04 of your test.
With your test displayed in the editor, do the
As in the
exercise, the test modifies the appropriate fields of the Select Date
and Location window of the Car Rental application. In addition,
upon conclusion, it issues a report line, which you can view by clicking the
Result Details subtab of the results, and observing
The Execute Test dialog box appears.
In the Test Modules panel, expand the
Ensure that only the check box for
test case TC 04 is
78: Car rental duration: 14 days, at a price of $420