lex-bot-tester is a framework and tool to create conversational tests for Amazon Alexa and Lex.
Instead of using a simulated version of the Skill it uses the existing SMAPI to deal with Alexa.
The tests can be created manually or automatically generated by a tool included, named urutu
. Right now, the code generation is python
but the Skill implementation can be in any supported language.
After you interact with the Skill from the command line, defining the conversation, the generated code looks like this
#! /usr/bin/env python
import sys
import unittest
from lex_bot_tester.aws.alexa.alexaskilltest import AlexaSkillTest
verbose = True
class GeneratedTests(AlexaSkillTest):
def test_book_my_trip_reserve_car(self):
"""
Test generated by urutu on 2018-02-21 01:24:51
"""
skill_name = 'BookMyTripSkill'
intent = 'BookCar'
conversation = [{'slot': None, 'text': 'ask book my trip to reserve a car', 'prompt': None},
{'slot': 'CarType', 'text': 'midsize',
'prompt': 'What type of car would you like to rent, Our most popular options are economy, midsize, and luxury'},
{'slot': 'PickUpCity', 'text': 'vancouver',
'prompt': 'In what city do you need to rent a car?'},
{'slot': 'PickUpDate', 'text': 'tomorrow',
'prompt': 'What day do you want to start your rental?'},
{'slot': 'ReturnDate', 'text': 'next week',
'prompt': 'What day do you want to return the car?'},
{'slot': 'DriverAge', 'text': '25', 'prompt': 'How old is the driver for this rental?'}]
simulation_result = self.conversation_text(skill_name, intent, conversation, verbose=verbose)
self.assertSimulationResultIsCorrect(simulation_result, verbose=verbose)
if __name__ == '__main__':
unittest.main()
There is a more detailed explanation and some videos at Testing Alexa Skills — Autogenerated tests.