Use numeric and string variables, as well as constants, in your mixed
In the My
expressions test module you created
previously, create a new test case:
Place your cell pointer on a line somewhere below the existing set of
action lines (but before the FINAL section, if any).
Click Create New Test Case
on the toolbar.
A test case line similar to the following is inserted.
In the second column of the new line, assign the test
case an ID of TC 04 (if not already set to that
Press Tab to
advance to the next column, and provide a description for your test
case, such as adding variables to the mix.
Create several local variable action lines, as
local variable car model Grand Am
local variable car price 25000
local variable state of sale New York
local variable sales tax 7
Add the following report action, which performs string and
numeric operations on both constants and variables:
report # "Sales tax on a $" & car price & " " & car model & " sold in " & state of sale & " is " & (sales tax / 100) * car price & " dollars."
Now create another set of local variable action lines to
assign new values to the variables:
local variable car model Prius
local variable car price 42000
local variable state of sale Texas
local variable sales tax 4
Select the row of the report action line in its entirety
(headers included), and press Ctrl+C to copy.
Move your cell pointer a few rows past the last local
variable line, and press Ctrl+V to
Your test case should now resemble this:
Execute Test Case 04 of your test.
With your test displayed in the editor, do the
The status bar (at the bottom left of the
TestArchitect window) indicates the stages of the test as it progresses.
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
You have just seen how string and numeric variables and constants can be combined
into expressions using both types of operations (string and numeric). You have also
performed the same operation on two similar sets of data. Note that the second set of
action lines does not create new variables,
because local variables with those names and exact same scope already exist. It does,
however, replace the contents of those local variables with new
on, you will see how repetitive operations such as the identical
action lines can benefit from encapsulation
, which makes your
tests more powerful and reusable, and test writing more efficient.