Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.68 KB

README.md

File metadata and controls

28 lines (19 loc) · 1.68 KB

assistant-javatester

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.

Standalone dialog (via code)

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.

Standalone dialog (via configuration file)

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.

Dialog with custom orchestration layer

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.