Sample code and utilities for building unit tests with Watson Assistant.
Includes examples for unit testing:
- Standalone dialog (via code)
- Standalone dialog (via configuration file)
- Dialog with custom orchestration layer
This project extends from the Java SDK for Watson Assistant and uses JUnit 4.x.
ExampleTest_Code.java demonstrates how to test a Watson Assistant dialog by writing tests entirely in code. This allows maximal control of your tests, including ability to group common setup into shared functions.
ExampleTest_Parameterized.java uses a JUnit Parameterized test so that you can write your tests via configuration only. The sample configuration file format is as follows:
#testname,initial_context_var_name,initial_context_var_value
turn1_utterance,turn1_expected_response_substring,expected_context_var_name,expected_context_value
turn2_utterance,turn2_expected_response_substring,expected_context_var_name,expected_context_value
Each line can have 0-n context variable name/value pairs. Expected response substrings are also optional.
ExampleTest_Orchestrator.java demonstrates testing a conversational system that includes a simple orchestration layer. The test makes use of test doubles, however you can also use mocks to similar effect. Loose coupling in your orchestration layer is critical to enabling easy unit testing.