Unit testing

You can use unit tests to ensure your bot will run through your defined user stories while you are working on the bot.

Input format

Input Description Example
msg> Text message sent by the user to the bot msg> How are you?
msg< Text message sent by the bot to the user msg< I'm fine.
int> Intent that was understood from the user message int> Intro/HowAreYou()
int< Bot intent with which the bot responds int< Intro/ReHowAreYou()
ctx> Context parameter that is set ctx> user.firstName = "Freddy"
ctx< Context parameter that is tested after executing the turn ctx< global.score >= 0
\# Comment
--- Separator between dialogs

Additionally, the following rules apply:

  • For each turn you need to specify a user input. Everything else is optional.
  • The text of the bot response (msg<) can be a regular expression.
  • Testing bot intents (int<) currently only checks intent labels, not slots.
  • The conversation is reset for each dialog (separated by a line ---).

Here is an example of a valid test:

\# Happy path for flight search

msg> Hey there
int> Intro/Greeting()

msg> I want to fly from SF to London
int> FlightSearch/Find(source="SANFRANCISCO", destination="LONDON")
ctx< global.source="SANFRANCISCO"
ctx< global.destination="LONDON"
msg< Cool, when do you want to fly?

msg> Sometime next week
msg< (Alright|Ok), .*