A library to support testing of domain packages.
Currently alpha code
npm install @numical/ubibot-test
Use this library along with a channel-specific test runner to create 'black-box' tests of your domain.
- install necessary packages
npm install @numical/ubibot-test @numical/ubibot-config @numical/{channel package}
- Create a directory containing one or more test script files of the form:
bot:aaaaaa user:bbbbb bot:cccccc bot:dddddd user:eeeee bot:ffffff
- Point the configuration
scriptsDir
value to this directory; - Select a test runner supplied by a channel package such as ubibot-channel-cli;
- Combine in a test module - see bankbot.test.js for an example.
- first line can optionally contain one of these commands:
ignore
ignore this scriptonly
run only this (and otheronly
) scripts
- otherwise all lines must be prefixed with the source:
bot:
what ubibot is expected to say;user:
what the user is expected to say;
- there should be no space between the prefix and the expected value:
ubibot:Hello << correct ubibot: Hello << incorrect
- the first prefixed line will be ubibot's initial prompt when started;
- the last line should be ubitbot's final response;
- where you want to accept any output from Ubibot, use the special syntax:
ubibot:[*]
- for cases where you wish to test multiple user inputs that incur the same ubibot response use the following syntax:
This will cause the script to be run three times, eaach time using one of these values.
user:[hello|hllo|hi]
Beware of the combinatorial explosion if you use multiple multi-option lines in a single script.
Basic conversational user interfaces lend themselves to straightforward 'black box' testing, due to their repl -style semantics.
The above approach offers a simple means to assert a script of question/answers.
However 'cleverer' bots may not lend themselves to such simplistic testing.
More complex channels might offer bot-instigated communications via some form of notification mechanism.
Trickier, bots may be (or at least appear to be) less deterministic - offering several versions of an answer to a specific question.
This library will attempt to offer testing mechanisms for such cases.
- When this library is used, it has explicit side effects designed to help testing and debugging.