Working with mixed types
Combine numeric and string operations in single expressions, operating on both numeric and text values.
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 03
(if not already set to that value).Press
Tab
to advance to the next column, and provide a description for your test case, such asmixing it up
.
Add a report action with a concatenation expression combining text and numeric operands:
text report # "The sales tax in New York is " & 7 & " per cent."
Add another
report
action that combines both string and numeric operations, on both types of operand:text report # "So the sales tax on a $25000 Grand Am sold in New York is " & (7/100) * 25000 & " dollars."
Your test case should now resemble this:
Execute Test Case 03 of your test.
With your test displayed in the editor, do the following:
Click Execute on the toolbar.
The Execute Test dialog box appears.
In the Test Modules panel, expand the tree.
Ensure that only the check box for test caseTC 03is selected.
Click Execute.
The status bar (at the bottom left of the TestArchitect window) indicates the stages of the test as it progresses.
In the first report, the only numeric operand, the constant 7, has been converted to a string as a result of the concatenation operation. The expression of the second report adds numeric operations, mixing them with concatenation. Note that the numeric operations are performed first, having higher precedence than concatenation; once evaluated, the numeric result is again converted to string for the concatenation.