Var Map and Data Generationby Group Public on Wednesday November 18 2009 @ 14:49:44 (1/1 Points) |
|
| API ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
The Var context→ item is a special item which allows generation of simple data, such as the current time and random numbers.
Its contents are accessed just like any other map access.
# Assign to variable set %Now% as %Var:DateTime% Notice %Now% # or just use directly Notice %Var:DateTime%
Every access to the Var map will return a new value (based on the semantics of the item).
The elements
Var:DateTime
The current date and time.
Var:Random
An unsigned random number within the standard range of the host platform (such as 32-bit).
Var:RandomInt
Produces a signed integer value.
Var:RandomBool
Produces a true or false value. This can be used directly in a condition→.
if %Var:RandomBool% #Do something end
Var:UniqueString
Returns a pseudo-unique string every time it is called. Within one instance this is guaranteed. But over time it is not guaranteed (the time interval is currently about one year to millisecond precision).
This is usually enough when a unique string is needed for a string.
Var:Counter
Returns the next number in a counter each time it is accessed. This is reset to 0 for each instance of TestPlan.
Var:ClientEmail
A common case which produces a unique email address. This uses the context items Email.Client.Prefix and Email.Client.Suffix along with a unique string to create the address.
Var:Text
Refer to Var Text→
Custom Elements
These use a standard mechanism called DynamicObjects. They can be easily created in Java if you need a specialized generator, as is often the case.
There is currently no facility to define new dynamic objects from dotTest.
TestPlan Var Map and Data Generation
