Test Spec
Flows, intents, states and actions can be tested.
Intents Spec
To write an intent test spec, you should create a file <flow>_intents.spec.yml
in test folder.
Schema Definition:
schema: kata.ai/schema/kata-ml/1.0/test/intents
Fields:
flow : string
- Flow to be testeddesc : string
- Test descriptiontest : { [desc: string] : IntentTestDefinition }
- Test suite
Test Definition
Intent test definition consists of:
context : JsonObject
- Context preconditiondata : JsonObject
- Data preconditionmessage : Message
- Input messageexpect: IntentExpect
- Expected output
Expected Output
You can define, either partially or full the expected output of a test:
intent : string
- Name of intent to be expectedmatch : boolean
- true if you expect the test to match the intentattributes : { [attr:string] : value }
- expected attributes, can be matched partially
Example:
schema: kata.ai/schema/kata-ml/1.0/test/intents
flow: welcome
desc: Welcome flow intent test
test:
'should select language: bahasa indonesia':
context: # write your context here
data: # write your data here
message:
type: text
content: pilih bahasa indonesia
expect:
intent: selectLanguage
attributes:
language: bahasa indonesia
States Spec
To write an state test spec, you should create a file <flow>_states.spec.yml
in test folder.
Schema Definition:
schema: kata.ai/schema/kata-ml/1.0/test/states
Fields:
flow : string
- Flow to be testeddesc : string
- Test descriptiontest : { [desc: string] : StateTestDefinition }
- Test suite
Test Definition
Intent test definition consists of:
tate : string
- Name of state to be testedcontext : JsonObject
- Context preconditiondata : JsonObject
- Data preconditionintent : string
- Message intent to be simulatedattributes : JsonObject
- Message attribute to be simulatedmessage : Message
- Input messageexpect: StateExpect
- Expected output
Expected Output
You can define, either partially or full the expected output of a test:
state : string
- next statecontext : JsonObject
- expected output context, can be matched partiallydata : JsonObject
- expected output data, can be matched partiallyend : boolean
- expected output end
Example:
schema: kata.ai/schema/kata-ml/1.0/test/states
desc: Welcome State Test
flow: welcome
test:
'should go to main menu after selecting english':
state: langSel
intent: selectLanguage
attributes:
language: english
message:
type: text
content: 'english please'
expect:
data:
lang: en
state: mainMenu
Actions Spec
To write an action test spec, you should create a file <flow>_actions.spec.yml
in test folder.
Schema Definition:
schema: kata.ai/schema/kata-ml/1.0/test/actions
Fields:
flow : string
- Flow to be testeddesc : string
- Test descriptioncontext : JsonObject
- initial contextdata : JsonObject
- initial datatest : { [desc: string] : ActionTestDefinition }
- Test suite
Test Definition
Action test definition consists of:
state : string
- Name of state to be testedcontext : JsonObject
- Context preconditiondata : JsonObject
- Data preconditionintent : string
- Message intent to be simulatedattributes : JsonObject
- Message attribute to be simulatedmessage : Message
- Input messageexpect: ActionExpect[]
- Expected output
Expected Output
You can define, either partially or full the expected output of a test:
responses : Response[]
- expected responses
Example:
schema: kata.ai/schema/kata-ml/1.0/test/actions
desc: Welcome State Test
flow: welcome
test:
'should return mainMenu':
state: mainMenu
intent: selectLanguage
attributes:
language: english
message:
type: text
content: 'english please'
expect:
- action: sendMainMenu
Flow Spec
To write a flow test spec, you should create a file <flow>_flow.spec.yml
in test folder.
Schema Definition:
schema: kata.ai/schema/kata-ml/1.0/test/flow
Fields:
flow : string
- Flow to be testeddesc : string
- Test descriptionstate : string
- initial statedata : JsonObject
- Test descriptioncontext : JsonObject
- initial contextdata : JsonObject
- initial datatest : { [desc: string] : FlowTestDefinition }
- Test suite
Test Definition
Flow test definition consists of:
message : Message
- Input messageexpect: FlowExpect
- Expected output
Expected Output
You can define, either partially or full the expected output of a test:
state : string
- next stateintent : string
- matched intentcontext : JsonObject
- expected output context, can be matched partiallydata : JsonObject
- expected output data, can be matched partiallyend : boolean
- expected output endresponses : Response[]
- expected responsesattributes : JsonObject
- Message attribute to be simulated
Example:
schema: kata.ai/schema/kata-ml/1.0/test/actions
desc: Welcome State Test
flow: welcome
state: initialState
context: # initial context
data: # initial data
test:
'should select langauge':
message:
type: text
content: 'english please'
expect:
state: mainMenu
intent: selectLanguage
Contributing to the Documentation
Is something missing/incorrect? Please let us know by contacting support@kata.ai. If you know how to fix it straight away, don’t hesitate to create a pull request on this documentation’s GitHub repository.