Writing test cases
Test cases must be written in plain text directly in the interface or on text editor. By using the characters "<" and ">" we simulate a conversation between bot and user.
Important rules
- Each turn of the conversation is written as a line.
- The first turn is always the user and generally a greeting. Writing "hi" will suffice
- All HTML and SSML markups are ignored (they do not need to be included in test cases)
- Asserting multiline bot responses - system replaces new lines with spaces when asserting bot response. When writing a test, the user can just put space in the place of a new line in the bot response.
Basic symbols
Symbol | Description | Example |
|---|---|---|
> | user utterance |
|
< | bot response | < Hello! I am a Banking Bot! |
***< ** | Allow to use * wildcard in bot response |
|
?< | Allow to use regular expression in bot response | ?< My version is \d{3}.\d.* |
K*< | Do not resolve Knowledge Base Items keys in response. Changing the value of this Knowledge Base Item does not affect the correctness of the test case execution result. This solution support only explicit reference to Knowledge Base Item | K*< My name is {knowledge.name} These examples are NOT supported: |
// | comments (working only as a new line) | // Author: Adam Kowalski |
aA off | By default, all assertions are case-sensitive. If you want to disable this, you can use the | aA off
|
pnct off | By default, punctuation is taken into account and will affect the result of your tests. If you want punctuation to be ignored, use the |
|
Don't resolve Knowledge Base Items option supports only explicit reference to Knowledge Base Item. These examples are NOT supported:
K*< My age is {knowledge.age + 1}knowledge.get("proces_"+proces_id)
Skipping bot response assertion
You can skip some bot responses in the test case if you don't want to assert the whole conversation. Example:
Whole conversation | Skipped bot responses |
|---|---|
|
|
Additional assertions
Assertion | Description | Example |
|---|---|---|
NAME - command name PARAMETER - command parameter (JSON format is allowed) | Assert commands used by bot during conversation. | cmd campaign @ 4625 |
| Assert analytical tags used by bot during conversation. |
|
assert JAVASCRIPT | Assert responses, commands, tags etc. with JavaScript. The | Assert number of responses: Assert response message: |
Data mocking
Symbol | Description | Example |
|---|---|---|
| Mocking extra info data | << {"working_hours": "External_data"} |
TIME - mocked time in ISO 8601 or timestamp format | mocking current time for a single request | <t 2010-06-30T01:20+02:00 |
<i | mocking the values returned by integration. Mock should be added BEFORE additional verifications (e.g. cmd, tags) | <i { "success": true, "response": { "version": "prod-123" } }
|
Limitations
Between lines with User messages > there could be
- only one integration mock
- only one extra info mock
- only one time mock
- many tags assertions
- many bot response assertions
- many commands assertions
It is recommended to use mocks first then assertions
Example test case
// Author: Adam Kowalski
// This test case validates fix: BOT-1234
> Hi
<< {"working_hours":"day"}
*< *Hi, my name is AdaBoT.* How can I help you?
> I want to make bank transfer.
# I_452
< Ok, our consutlant can help you with this issue.
> Ok, connect me with a consultant.
<i {"success": true, "response": "4123"
<t 1613720910194}
cmd redirect @ 4123
< You will be redirected to 4123 lineUpdated 10 days ago
