Creating test scenarios

In test scenarios, you list the entity loaders and event sequences that you want to load and submit. You can also write tests that check the values of entities and entity attributes. If you expect a certain result from a scenario, checking the value of an entity against this expected result can be a useful way to validate that the solution works correctly.

Before you begin

Before you can run test scenarios, you must create the entity loaders, event sequences, and the common definitions that you want include in a scenario.

About this task

You create and complete your test scenarios with the available constructs. Ensure that you close the construct with a semi-colon (;). After you run test scenarios on a test server, you can view the results in the Console tab and compare the results of your tests with the results that you expected.

Procedure

  1. Create a test scenario:
    1. Click File > New > Other > Insight Designer > Test Scenario.
    2. In the Test Scenario wizard, select a test client project in your workspace.
    3. Enter a name for your test scenario file.
    4. Click Finish. The test scenario editor opens.
  2. Press Space or Ctrl+Space to view the available constructs.
  3. If you want to add common definitions, use the using definitions from: - "<common definitions file>" ; construct. If you use this construct, it must be the first phrase in the scenario.
  4. Add an entity loader by using the load entities from "<entity loader file>" construct. To add more than one entity loader, create a list by using the load entities from: - "<entity loader file>" construct.
  5. Add an event sequence by using the submit events from "<event sequence file>" construct. To add more than one event sequence, create a list by using the submit events from: - "<event sequence file>" construct.
  6. Write a test to check on the existence of an entity by using the check that <entity> <exists/does not exist> construct. For example, to check that the entity "Betty" exists, you can write the following test:
    check that the customer "Betty" exists ;
  7. Write a test that checks the values of entity attributes by using the check that for <entity> : - <list of tests> construct. When the editor proposes : - <list of tests>, use the verbalized constructs to write your tests. In the following example, you check whether Betty's bank account has a current balance of 10000:
    check that for the customer "Betty" :
       - the current balance of the bank account of this customer is 10000 ;
  8. Optional: Write a statement in which you simulate the passing of time, which can trigger scheduled events or rules, by using the continue processing until <date> syntax.

    In the following example, an event sequence that contains David's transactions is submitted to the server on 02/24/15, and then a test checks whether his status is GOLD. A customer has a status of GOLD after a set of transactions is made, so you expect David's status to be GOLD. Next, to check what happens when time passes, two tests check David's status after intermittent periods of time. The continue processing until <date> syntax simulates the passing of time from the timestamp in the event sequence to the <date> specified in this syntax, during which events can be scheduled. In this example, no other transaction events are scheduled for David. A first test checks that his status is SILVER on 08/24/15, and a second test checks that his status is BRONZE on 02/24/16. As time passes from the timestamp in the event sequence event to 08/24/15 and then to 02/24/16, David's status goes from GOLD to SILVER and then to BRONZE as a result. The customer status is lowered because, as time passes, David makes no new transactions.

    submit events from "transactions until gold" ; 
    
    check that for the customer "David":  
       - the status of this customer is GOLD ; 
    
    continue processing until 08/24/15 ; 
    
    check that for the customer "David" :  
       - the status of this customer is SILVER ; 
    
    continue processing until 02/24/16 ; 
    
    check that for the customer "David" :  
       - the status of this customer is BRONZE ;
  9. Save your work. The file is stored in the Test Scenarios folder of your test client project.

Example

In the following example, entities from two entity loaders (customer_ids and items) are loaded and events from two event sequences (purchases and returns) are submitted to the server. Next, a test checks the attributes for the entity Betty. The test checks Betty's name, occupation, and address.

load entities from:
   - "customer_ids" 
   - "items" ;

submit events from : 
   - "purchases" 
   - "returns" ;

check that for the customer "Betty" :
    - the name of this customer is "Betty"
    - the occupation of this customer is not "Software Architect" 
    - the address of this customer is not null 
    - the occupation of this customer is not null ;

The following example uses number operators to check that the age of the customer falls within a range.

check that for the customer "Betty" :
    - the age of this customer is between 18 and 65
    - the age of this customer is more than 21
    - the age of this customer is at most 50 ;