lex-bot-tester là một khuôn khổ và công cụ để tạo xét nghiệm đàm thoại cho Amazon Alexa và Lex.
Thay vì sử dụng phiên bản mô phỏng của Kỹ năng, nó sử dụng SMAPI hiện có để xử lý Alexa.
Các thử nghiệm có thể được tạo bằng tay hoặc được tạo tự động bởi một công cụ được bao gồm, có tên là urutu
. Ngay bây giờ, việc tạo mã là python
nhưng việc thực hiện Kỹ năng có thể bằng bất kỳ ngôn ngữ được hỗ trợ nào.
Sau khi bạn tương tác với các kỹ năng từ dòng lệnh, xác định cuộc nói chuyện, các mã được tạo trông như thế này
#! /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()
Có một lời giải thích chi tiết và một số video tại Testing Alexa Skills — Autogenerated tests.