Test scenario syntax
The test scenario syntax is the set of statements that you can write to load entity loaders, submit event sequences, and run tests in a single test file. In a test scenario, you can write tests to check the values and attributes of your entities, and the state of your events.
Purpose
Test scenario files are stored in the solution test client project. To test the values of your entities, entity attributes, and the state of your events, you can load entities, submit events, and then use the available constructs to run tests on the entities and events on your test server.Syntax
The following syntax shows the constructs that you can use when you write a test scenario.
[using definitions from "<entity loader file>" ;]
[load entities from "<entity loader file>" ;]
[load entities from:
- "<entity loader file>" ;]
[submit events from "<event sequence file>" [, time-stamped <date & time>] ;]
[submit events from "<event sequence file>" [, time-stamped calendar duration] ;]
[submit events from :
- "<event sequence file>" ;]
[continue processing until <date> ;]
[continue processing for <calendar duration> ;]
[check that <entity> <exists/does not exist> ;]
[check that <event aggregate> is [at least/at most/between <number> and/less than/more than/not/strictly between <number> and] <number> ;]
[check that for <entity> [identified by <entity id>] :
- <list of tests> ;]
[check that for <the event>/<all events> in the events emitted [by <agent>][where <test>] : <list of tests> ;]
[check that there are <number> <events> in the events emitted [by <agent>] [where <test>] ;]
[empty the events emitted ;]
The events that you want to check can be filtered by various criteria, such as events emitted by specific agents. To match multiple agents, you can add an asterisk (*) to the end of an agent string.
| Construct | Description | Example |
|---|---|---|
|
|
Detects the existence or absence of a specific entity. |
|
check that <event
aggregate> is [at least/at most/between <number> and/less than/more
than/not/strictly between <number> and] <number>
; |
Checks the value of a global event aggregate at the current point in a test scenario. |
|
|
|
Verifies the expected results of a list of tests on a specified entity. This construct checks that the values of your entity correspond to the values expected in your list of tests. |
|
|
|
Verifies the expected results of a list of tests. This construct identifies an entity by the ID and checks the values that you expect from your list of tests. |
|
|
|
Checks the attributes of an event in a specified subset of the events that are emitted, since the start of the test |
|
|
|
Checks the attributes of all members of a specified subset of the events that are emitted, since the start of the test. |
|
|
|
Checks the number of events emitted either by a specific agent, by an event, or by both. |
|
|
|
Simulates the passing of time from the date of the last event in an event sequence to the date
and time that you define in the |
|
|
|
Simulates the passing of time from the date of the last event in an event
sequence for time specified by the <calendar duration>
construct. |
|
|
|
Disregards the events that are previously emitted in the test scenario. The events that are emitted by the solution before this statement are ignored in subsequent "check" statements. |
|
|
|
Loads entities from a single entity loader file. |
|
|
|
Loads entities from a list of entity loader files. |
|
|
|
Submits events from a single event sequence file. If the event sequence that you submit uses the |
|
|
|
Submits events from a list of event sequence files. |
|
|
|
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. |
|
Example
The following test scenario uses common definitions, an entity loader, and four event sequences.
In the first test, you check that the alert in the alerts event sequence is low.
Then, you clear the events before running various checks on a customer named Fred. The test moves
forward in time to 11/06/2015 by using the continue processing
until construct.
using definitions from "customer definitions" ;
submit events from "alerts" time-stamped 23/3/2016 11:00:00 AM ;
check that for the alert in the events emitted :
- the level of this alert is low ;
submit events from "alerts" , time-stamped 2 hours later ;
check that for the alert in the events emitted :
- the level of this alert is medium ;
empty the events emitted ;
load entities from "customers" ;
submit events from "none to bronze" ;
check that for the customer identified by 'Fred' :
- the age of this customer is between 18 and 65
- the address of this customer is not null
- the phone number of this customer is not null ;
check that for the customer 'Fred' :
- the status of this customer is BRONZE ;
submit events from "bronze to silver" ;
check that for the status change in the events emitted
by "CustomerLoyaltyAgent" :
- the customer id of the customer of this status change is "Fred"
- the new status of this status change is SILVER ;
check that for the customer 'Fred' :
- the status of this customer is SILVER ;
submit events from "silver to gold" ;
check that for the customer 'Fred' :
- the status of this customer is GOLD ;
continue processing until 11/6/2015 ;
check that for the customer 'Fred' :
- the status of this customer is SILVER ;