Common definitions syntax
You can use the common definitions files to create definitions that can be referenced by entity loader and event sequence files. You can also reference a common definitions file from within another common definitions file.
Purpose
Common definitions are files that store definitions that can be used in other test files. You define the common definitions in the common definitions editor, and the file is stored in the test client project.Syntax
The following syntax shows all of the constructs you can add to a common definitions file. All of the constructs are optional. Use as many constructs as it takes to define a test scenario or reusable subset of a scenario.
[using definitions from:
- "<common definitions file>" ;]
[define <variable> as <value> [where
<entity type> <entity id>
<entity type> identified by <entity id>] ;]
[add <value> to <collection> ;]
[clear <list> of <object> ;]
[make it <true or false> that <object> is <boolean field>;]
[remove <an object> from <a list> ;]
[set <attribute> of <object> to <value>;]
If you use the optional using definitions from : <common definitions file> construct, it must be the first phrase in the test files. Do not create circular dependencies by which two common definitions files reference each other.
Construct | Description | Example |
---|---|---|
<entity type> <entity id> |
Short construct that specifies a relationship between the bound entity and the event. |
|
<entity type> identified by <entity id> |
Specifies a relationship between the bound entity and the event. |
|
add <value> to <collection> ; |
Adds an object to a collection. The target of this construct cannot be a relationship. |
|
define <variable> as <value> ; |
Defines a variable. The value of the variable can be an object or a constant. Variables can be used in the definition of the event emission. |
|
clear <list> of <object> ; |
Clears a collection or removes a relationship between two objects. The clear <list> keywords specify the collection or types of relationship, and the of <object> keywords define the entity or event that you want to clear from the relationship or collection. |
|
make it <true or false> that <object> is <boolean field>; |
Replaces the value of a boolean attribute. |
|
remove <an object> from <a list> ; |
Removes an item from a list. The remove <object> keywords specify the object that you want to remove, and the from <a list> keywords define the collection from which you want to remove the object. |
|
set <attribute> of <object> to <value>; |
Replaces the value of an attribute with the value of another type. Values can be simple, relationship, geospatial, or complex types. |
|
using definitions from: - "<common definitions file>" ; |
Specifies the common definitions file or files from which an entity loader, event sequence, or common definitions file uses the definitions. When you use this construct, it must be used in the header of the file and precede all of the other constructs. |
|
Examples
In the following example in which shopping cart 1 is defined, two common definition files (customer_ids and items) are referenced to provide the customer IDs and shopping cart items.
using definitions from:
- "customer_ids"
- "items" ;
define 'shopping cart 1' as a new shopping cart where
the id is '123',
the customer is the customer identified by 'Jane';
add a new item identified by 'bread' to 'shopping cart 1';