테스트 시나리오 작성

엔티티 및 이벤트에 테스트를 실행하여 솔루션이 예상대로 작동하는지 확인할 수 있습니다. 테스트 시나리오에서는 엔티티를 로드하고 단일 파일에서 이벤트를 제출한 후 엔티티 값, 엔티티 속성 및 사용자 서버의 이벤트를 확인하는 테스트를 작성할 수 있습니다.

시작하기 전에

엔티티 및 이벤트를 테스트하기 전에 먼저 시나리오에 포함시킬 공통 정의, 엔티티 로더, 이벤트 순서를 작성해야 합니다.

이 태스크 정보

시나리오를 작성하고 각 생성은 세미콜론(;)으로 끝나야 합니다. 테스트 결과는 사용자가 이러한 결과를 사용자의 예상과 비교할 수 있도록 콘솔 탭에서 표시합니다.

프로시저

  1. 테스트 시나리오를 작성하십시오.
    1. 솔루션 프로젝트를 선택하고 솔루션 맵에서 테스트 시나리오 작성을 클릭하십시오.
    2. 테스트 시나리오 마법사에서는 작업공간에서 테스트 클라이언트 프로젝트를 선택하고 테스트 시나리오 파일의 이름을 입력하십시오.
    3. 완료를 클릭하십시오. 테스트 시나리오 편집기가 열립니다.
  2. 스페이스 또는 Ctrl+스페이스를 눌러서 사용 가능한 구성을 보십시오.
  3. using definitions from: - "<common definitions file>" 생성을 사용하여 공통 정의를 추가하십시오. 이 생성을 사용하는 경우 테스트 시나리오에서 첫 번째 구문이어야 합니다.
  4. load entities from "<entity loader file>" 및 submit events from "<event sequence file>" 생성을 사용하여 엔티티를 로드하고 이벤트를 제출하십시오.
    참고: time-stamped by the test scenario 생성을 포함하는 이벤트 순서에는 이벤트 순서가 제출될 때마다 절대 시간소인이 있어야 합니다.
  5. 테스트를 작성하여 엔티티의 상태를 확인하십시오.
    • check that <entity> <exists/does not exist> 생성을 사용하여 엔티티의 존재 여부를 확인하십시오.예제:
      check that the customer "John" exists ;
    • check that for <entity> [identified by <entity id>] 생성을 사용하여 엔티티의 속성을 테스트하십시오. 편집기가 <list of tests>를 제안하는 경우, 자연어 처리된 생성을 사용하여 테스트를 작성하십시오.예제:
      check that for the customer identified by "John" :
         - the address of this customer is not null ; 
  6. 생성된 이벤트의 수 및 네이처를 확인하기 위한 테스트를 작성하십시오.
    • check that for <event> emitted 생성을 사용하여 시나리오에서 생성한 특정 이벤트의 컨텐츠를 테스트하십시오. 예제:
      check that for the delivery van request in the events emitted by "Delivery_van_agent" :
         - it is not true that the driver of the delivery van of this delivery van request is null ;
    • check that there are <number> <events> in the events emitted 생성을 사용하여 시나리오나 특정 에이전트에서 생성하는 예상 특정 이벤트 수를 테스트하십시오.예:
      check that there are 2 events in the events emitted
         by "Delivery_van_agent" ;
    • check that for <the event>/<all events> in the events emitted 생성을 사용하여 시나리오 또는 특정 에이전트에서 생성하는 이벤트 하나 또는 모두를 테스트하십시오.
      check that for all events in the events emitted by "Delivery_van_agent" :
         - it is not true that each event is null ; 
    • check that <event aggregate> is 생성을 사용하여 글로벌 이벤트 집계 값을 테스트하십시오.
      check that the number of 'delivery events' is between 6 and 10 ; 
    참고: 테스트 시나리오 check that <aggregate> is 명령문은 글로벌 이벤트 집계만 지원합니다.
  7. continue processing 및 empty the events emitted 생성을 추가하여 테스트 시나리오에서 중요한 시간을 단축하거나 늘리십시오. 이벤트를 무시하기 위한 empty the events emitted 생성이 이 명령문보다 먼저 생성됩니다. 이 명령문을 사용하기 전에 솔루션이 생성한 이벤트는 후속 확인 명령문에서 무시됩니다. continue processing until <date> 생성은 시간 경과를 시뮬레이션합니다. 지정된 날짜와 시나리오의 마지막 단계 사이의 기간은 처리하도록 스케줄링된 이벤트 중 트리거되는 이벤트를 정의합니다.
  8. 작업을 저장하십시오. 이 파일은 테스트 클라이언트 프로젝트의 테스트 시나리오 폴더에 저장됩니다.

예

다음 예제에서는 두 엔티티 로더(customer_ids 및 items)의 엔티티가 로드되고 두 이벤트 순서(purchases 및 returns)의 이벤트가 서버에 제출됩니다. 그 다음에는 테스트가 엔티티 Betty의 속성을 확인합니다. 이 테스트는 Betty의 이름, 직업 및 주소를 확인합니다.

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 ;

다음 예제는 숫자 연산자를 사용하여 고객의 나이가 특정 범위 내에 포함되는지 확인합니다.

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 ;

다음 예제에서 트랜잭션 세트를 작성한 후 고객은 GOLD 상태입니다. 시간이 경과하면서 발생하는 내용을 확인하기 위해, 세 번의 테스트에서 간헐적 기간 이후의 David 상태를 확인합니다. continue processing until <date> 생성은 이벤트 순서의 마지막 시간소인부터 지정된 <date>까지의 시간 경과를 시뮬레이션하고, 이 기간 동안 이벤트가 스케줄링될 수 있습니다. 이 예제에서는 David에게 다른 트랜잭션 이벤트가 스케줄되어 있지 않습니다. 테스트는 상태가 08/24/15 당시 SILVER인지 확인하고, 다른 테스트는 상태가 변경되었는지 확인하며, 세 번째 테스트는 상태가 02/24/16 당시 BRONZE인지를 확인합니다. 이벤트 순서 이벤트의 마지막 시간소인 이후 08/24/15까지 그리고 02/24/16까지 시간이 경과하면서, David의 상태는 결과로서 GOLD에서 SILVER로, 그리고는 BRONZE로 변경되었습니다. 시간이 지남에 따라 David가 새 트랜잭션을 작성하지 않으므로 고객 상태는 낮아집니다.

submit events from "transactions until gold" ; 

check that for the customer "David":  
   - the status of this customer is GOLD ; 

continue processing until 08/24/16 ; 

check that for the customer "David" :  
   - the status of this customer is SILVER ; 

check that for the status change in the events emitted
    by "CustomerLoyaltyAgent" :
    - the customer id of the customer of this status change is "David"
    - the new status of this status change is SILVER ;

continue processing until 02/24/17 ; 

check that for the customer "David" :  
   - the status of this customer is BRONZE ;