From 9b731444baae2a1f25c70f9d7c425abe324979a1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Fri, 18 May 2018 11:21:05 -0500 Subject: [PATCH 01/12] First draft version for skill-tester v0.3.2 --- .gitignore | 3 + lambda/custom/package-lock.json | 138 ++++++++++++++++++++++++++++++++ skill-testing.json | 8 ++ test/en-US.yml | 83 +++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 .gitignore create mode 100644 lambda/custom/package-lock.json create mode 100644 skill-testing.json create mode 100644 test/en-US.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73d651e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# No IDE file +./idea +lambda/custom/node_modules/ diff --git a/lambda/custom/package-lock.json b/lambda/custom/package-lock.json new file mode 100644 index 0000000..c98d857 --- /dev/null +++ b/lambda/custom/package-lock.json @@ -0,0 +1,138 @@ +{ + "name": "skill-sample-nodejs-highlowgame", + "version": "2.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ask-sdk": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/ask-sdk/-/ask-sdk-2.0.5.tgz", + "integrity": "sha512-SYNOFpuFAjz3Z5/7a9Lq8G1XzJ9zdDlYsb1ZUHvZO3Xr4tc/wAWH4kP3OK6IXV9kHJs3cLnJjmuMHKH8DVwfIw==", + "requires": { + "ask-sdk-core": "2.0.5", + "ask-sdk-dynamodb-persistence-adapter": "2.0.5", + "ask-sdk-model": "1.2.0" + } + }, + "ask-sdk-core": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/ask-sdk-core/-/ask-sdk-core-2.0.5.tgz", + "integrity": "sha512-XW95Wh+eMgOGBJKv15NvNip5QabOYu4nVw2qpZvb1PYZiw5ERVESiX26As+S/Iy63ZC7YbiI+o667z93xlUHKw==" + }, + "ask-sdk-dynamodb-persistence-adapter": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/ask-sdk-dynamodb-persistence-adapter/-/ask-sdk-dynamodb-persistence-adapter-2.0.5.tgz", + "integrity": "sha512-VJRHRTl6KNs9DJYdB5n4BArsvZgpDHpybKtRzEWrI69JJprfobJo6LCr2ghh+vTLQJJ8fb0jDp7quL5wOYO/rw==", + "requires": { + "aws-sdk": "2.241.1" + } + }, + "ask-sdk-model": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ask-sdk-model/-/ask-sdk-model-1.2.0.tgz", + "integrity": "sha512-GD9WwIq8c5fparwZOQm2IxboDu5cs6JMsgFISQIVUNmCdnprxr5PgaQMA55JOGs94bwIEJ6gc8i1mVyfFX75Vw==" + }, + "aws-sdk": { + "version": "2.241.1", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.241.1.tgz", + "integrity": "sha1-rk4bp3LMFyhN8AwDtY3PkU1ccvk=", + "requires": { + "buffer": "4.9.1", + "events": "1.1.1", + "ieee754": "1.1.8", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.1.0", + "xml2js": "0.4.17" + } + }, + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "requires": { + "base64-js": "1.3.0", + "ieee754": "1.1.8", + "isarray": "1.0.0" + } + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, + "xml2js": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", + "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", + "requires": { + "sax": "1.2.1", + "xmlbuilder": "4.2.1" + } + }, + "xmlbuilder": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", + "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", + "requires": { + "lodash": "4.17.10" + } + } + } +} diff --git a/skill-testing.json b/skill-testing.json new file mode 100644 index 0000000..faa33bb --- /dev/null +++ b/skill-testing.json @@ -0,0 +1,8 @@ +{ + "handler": "lambda/custom/index.js", + "locale": "en-US", + "jest": { + "silent": true, + "coveragePathIgnorePatterns": [] + } +} \ No newline at end of file diff --git a/test/en-US.yml b/test/en-US.yml new file mode 100644 index 0000000..4313d37 --- /dev/null +++ b/test/en-US.yml @@ -0,0 +1,83 @@ +#===================================================================================================================== +# ██████╗ ███████╗███████╗██████╗ ██████╗ ██╗ ██╗███████╗███╗ ██╗ +# ██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝████╗ ██║ +# ██████╔╝█████╗ ███████╗██████╔╝██║ ██║█████╔╝ █████╗ ██╔██╗ ██║ +# ██╔══██╗██╔══╝ ╚════██║██╔═══╝ ██║ ██║██╔═██╗ ██╔══╝ ██║╚██╗██║ +# ██████╔╝███████╗███████║██║ ╚██████╔╝██║ ██╗███████╗██║ ╚████║ +# ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ +# +# Test type: Functional/End-to-End/Regression +# Skill name: "High Low Game" by Amazon +# Test scope: LaunchRequest, NumberGuessIntent, AMAZON.HelpIntent, AMAZON.StopIntent, +# AMAZON.CancelIntent, AMAZON.YesIntent, AMAZON.NoIntent +#===================================================================================================================== + +--- +configuration: + locale: en-US + dynamo: mock + userId: 000000 + +--- +- test: "Sequence 01. Test scenario: launch request, no further interaction." +- LaunchRequest: + - response.outputSpeech.ssml: "Welcome to High Low guessing game. You have played * times. would you like to play?" + - response.reprompt.outputSpeech.ssml: "Say yes to start the game or no to quit." + - response.shouldEndSession: false + - response.card: undefined + - sessionAttributes.gamesPlayed: 0 + - sessionAttributes.endedSessionCount: 0 + +--- +- test: "Sequence 02. Test scenario: Invoke NumberGuessIntent. Focus on user interaction." +- LaunchRequest: +- no: + - response.outputSpeech.ssml: "Ok, see you next time!" + - sessionAttributes.gamesPlayed: 0 + - sessionAttributes.endedSessionCount: 1 + +- LaunchRequest: +- yes: + - response.outputSpeech.ssml: "Great! Try saying a number to start the game." + - response.reprompt.outputSpeech.ssml: "Try saying a number." + - response.shouldEndSession: false + - sessionAttributes.gamesPlayed: 1 + - sessionAttributes.guessNumber: "*" + - sessionAttributes.endedSessionCount: 1 +- fifty: + - response.outputSpeech.ssml == "50 is too low." goto "seventy five" + - response.outputSpeech.ssml == "50 is too high." goto "twenty five" + - response.outputSpeech.ssml == "50 is correct! Would you like to play a new game?" goto "no" + - response.reprompt.outputSpeech.ssml: "Try saying a larger number." + - response.reprompt.outputSpeech.ssml: "Try saying a lower number." +- "seventy five": + - response.outputSpeech.ssml: "75 is too low." #goto "one hundred" + - response.outputSpeech.ssml: "75 is too high." #goto "thirty eight" + - response.outputSpeech.ssml == "75 is correct! Would you like to play a new game?" goto "no" + - response.reprompt.outputSpeech.ssml: "Try saying a larger number." + - response.reprompt.outputSpeech.ssml: "Try saying a lower number." +- stop: "*" +- "twenty five": + - response.outputSpeech.ssml: "25 is too low." #goto "thirty eight" + - response.outputSpeech.ssml: "25 is too high." #goto "thirteen" + - response.outputSpeech.ssml == "25 is correct! Would you like to play a new game?" goto "no" + - response.reprompt.outputSpeech.ssml: "Try saying a larger number." + - response.reprompt.outputSpeech.ssml: "Try saying a lower number." +- stop: "*" +- no: + - response.outputSpeech.ssml: "Ok, see you next time!" + - sessionAttributes.gamesPlayed: 2 + - sessionAttributes.guessNumber: "*" + - sessionAttributes.endedSessionCount: 2 + +--- +# It would be great to use some of the values that comes in the response as utterances to improve interaction +- test: "Sequence 03. Test scenario: Invoke NumberGuessIntent and say no" +- LaunchRequest: +- yes: +- sessionAttributes.guessNumber: "* is correct! Would you like to play a new game?" +- no: + - response.outputSpeech.ssml: "Ok, see you next time!" + - sessionAttributes.gamesPlayed: 2 + - sessionAttributes.guessNumber: "*" + - sessionAttributes.endedSessionCount: 2 \ No newline at end of file From ef8d3b622946495c4390ba24b8366998bb0db71c Mon Sep 17 00:00:00 2001 From: John Kelvie Date: Thu, 24 May 2018 19:59:39 -0500 Subject: [PATCH 02/12] Changes to tests based on debugging --- .gitignore | 3 ++- lambda/custom/index.js | 5 +++++ skill-testing.json | 2 +- test/en-US.yml | 35 ++++++++++++++++++----------------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 73d651e..4afd0fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # No IDE file -./idea +.idea lambda/custom/node_modules/ +coverage \ No newline at end of file diff --git a/lambda/custom/index.js b/lambda/custom/index.js index 2ca2fa7..91f4f42 100644 --- a/lambda/custom/index.js +++ b/lambda/custom/index.js @@ -104,6 +104,11 @@ const YesIntent = { sessionAttributes.gameState = 'STARTED'; sessionAttributes.guessNumber = Math.floor(Math.random() * 101); + // For testing purposes, force a number to be picked if the UNIT_TEST environment variable is set + if (process.env.UNIT_TEST) { + sessionAttributes.guessNumber = 50; + } + return responseBuilder .speak('Great! Try saying a number to start the game.') .reprompt('Try saying a number.') diff --git a/skill-testing.json b/skill-testing.json index faa33bb..f78e3f4 100644 --- a/skill-testing.json +++ b/skill-testing.json @@ -2,7 +2,7 @@ "handler": "lambda/custom/index.js", "locale": "en-US", "jest": { - "silent": true, + "silent": false, "coveragePathIgnorePatterns": [] } } \ No newline at end of file diff --git a/test/en-US.yml b/test/en-US.yml index 4313d37..14c0e63 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -19,23 +19,27 @@ configuration: userId: 000000 --- -- test: "Sequence 01. Test scenario: launch request, no further interaction." +- test: "Sequence 01. Test scenario: launch request, play a game" - LaunchRequest: - - response.outputSpeech.ssml: "Welcome to High Low guessing game. You have played * times. would you like to play?" + - response.outputSpeech.ssml: "Welcome to High Low guessing game. You have played 0 times. would you like to play?" - response.reprompt.outputSpeech.ssml: "Say yes to start the game or no to quit." - response.shouldEndSession: false - response.card: undefined - sessionAttributes.gamesPlayed: 0 - sessionAttributes.endedSessionCount: 0 +- yes +- 50 --- - test: "Sequence 02. Test scenario: Invoke NumberGuessIntent. Focus on user interaction." - LaunchRequest: - no: - response.outputSpeech.ssml: "Ok, see you next time!" - - sessionAttributes.gamesPlayed: 0 + - sessionAttributes.gamesPlayed: 1 - sessionAttributes.endedSessionCount: 1 +--- +- test: "Sequence 03. Test scenario: Invoke NumberGuessIntent. Focus on user interaction." - LaunchRequest: - yes: - response.outputSpeech.ssml: "Great! Try saying a number to start the game." @@ -44,23 +48,20 @@ configuration: - sessionAttributes.gamesPlayed: 1 - sessionAttributes.guessNumber: "*" - sessionAttributes.endedSessionCount: 1 -- fifty: - - response.outputSpeech.ssml == "50 is too low." goto "seventy five" - - response.outputSpeech.ssml == "50 is too high." goto "twenty five" - - response.outputSpeech.ssml == "50 is correct! Would you like to play a new game?" goto "no" +- 40: + - response.outputSpeech.ssml == "40 is too low." goto "75" + - response.outputSpeech.ssml == "40 is too high." goto "50" + - response.outputSpeech.ssml == "40 is correct! Would you like to play a new game?" goto "no" - response.reprompt.outputSpeech.ssml: "Try saying a larger number." - response.reprompt.outputSpeech.ssml: "Try saying a lower number." -- "seventy five": - - response.outputSpeech.ssml: "75 is too low." #goto "one hundred" - - response.outputSpeech.ssml: "75 is too high." #goto "thirty eight" +- 75: + - response.outputSpeech.ssml == "75 is too high." goto "50" - response.outputSpeech.ssml == "75 is correct! Would you like to play a new game?" goto "no" - response.reprompt.outputSpeech.ssml: "Try saying a larger number." - response.reprompt.outputSpeech.ssml: "Try saying a lower number." - stop: "*" -- "twenty five": - - response.outputSpeech.ssml: "25 is too low." #goto "thirty eight" - - response.outputSpeech.ssml: "25 is too high." #goto "thirteen" - - response.outputSpeech.ssml == "25 is correct! Would you like to play a new game?" goto "no" +- 50: + - response.outputSpeech.ssml == "50 is correct! Would you like to play a new game?" goto "no" - response.reprompt.outputSpeech.ssml: "Try saying a larger number." - response.reprompt.outputSpeech.ssml: "Try saying a lower number." - stop: "*" @@ -72,12 +73,12 @@ configuration: --- # It would be great to use some of the values that comes in the response as utterances to improve interaction -- test: "Sequence 03. Test scenario: Invoke NumberGuessIntent and say no" +- test: "Sequence 04. Test scenario: Invoke NumberGuessIntent and say no" - LaunchRequest: - yes: -- sessionAttributes.guessNumber: "* is correct! Would you like to play a new game?" + - sessionAttributes.guessNumber: 50 - no: - response.outputSpeech.ssml: "Ok, see you next time!" - sessionAttributes.gamesPlayed: 2 - sessionAttributes.guessNumber: "*" - - sessionAttributes.endedSessionCount: 2 \ No newline at end of file + - sessionAttributes.endedSessionCount: 3 \ No newline at end of file From a05928ccfbee1387283d21c5fb412bd0ebcdebaa Mon Sep 17 00:00:00 2001 From: John Kelvie Date: Tue, 29 May 2018 13:06:57 -0500 Subject: [PATCH 03/12] Updated for testability --- test/en-US.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/en-US.yml b/test/en-US.yml index 14c0e63..086c28d 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -42,13 +42,14 @@ configuration: - test: "Sequence 03. Test scenario: Invoke NumberGuessIntent. Focus on user interaction." - LaunchRequest: - yes: - - response.outputSpeech.ssml: "Great! Try saying a number to start the game." + - response.outputSpeech.ssml === test - response.reprompt.outputSpeech.ssml: "Try saying a number." - response.shouldEndSession: false - sessionAttributes.gamesPlayed: 1 - sessionAttributes.guessNumber: "*" - sessionAttributes.endedSessionCount: 1 - 40: + - exit - response.outputSpeech.ssml == "40 is too low." goto "75" - response.outputSpeech.ssml == "40 is too high." goto "50" - response.outputSpeech.ssml == "40 is correct! Would you like to play a new game?" goto "no" @@ -79,6 +80,6 @@ configuration: - sessionAttributes.guessNumber: 50 - no: - response.outputSpeech.ssml: "Ok, see you next time!" - - sessionAttributes.gamesPlayed: 2 + - sessionAttributes.gamesPlayed: 5 - sessionAttributes.guessNumber: "*" - sessionAttributes.endedSessionCount: 3 \ No newline at end of file From a386e2f46e444187a6044cf840786ed260fb69f6 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Wed, 30 May 2018 10:54:23 -0500 Subject: [PATCH 04/12] First complete draft version for skill-tester 0.4.1 --- skill-testing.json | 3 +- test/en-US.yml | 74 ++++++++++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/skill-testing.json b/skill-testing.json index f78e3f4..7a485c9 100644 --- a/skill-testing.json +++ b/skill-testing.json @@ -1,8 +1,9 @@ { "handler": "lambda/custom/index.js", "locale": "en-US", + "trace": "false", "jest": { - "silent": false, + "silent": true, "coveragePathIgnorePatterns": [] } } \ No newline at end of file diff --git a/test/en-US.yml b/test/en-US.yml index 086c28d..c8779a6 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -19,7 +19,7 @@ configuration: userId: 000000 --- -- test: "Sequence 01. Test scenario: launch request, play a game" +- test: "Sequence 01. Test scenario: launch request, play one game" - LaunchRequest: - response.outputSpeech.ssml: "Welcome to High Low guessing game. You have played 0 times. would you like to play?" - response.reprompt.outputSpeech.ssml: "Say yes to start the game or no to quit." @@ -27,59 +27,75 @@ configuration: - response.card: undefined - sessionAttributes.gamesPlayed: 0 - sessionAttributes.endedSessionCount: 0 -- yes -- 50 +- yes: + - response.outputSpeech.ssml: "Great! Try saying a number to start the game." + - response.reprompt.outputSpeech.ssml: "Try saying a number." + - response.shouldEndSession: false +- 50: + - response.outputSpeech.ssml: "50 is correct! Would you like to play a new game?" + - response.reprompt.outputSpeech.ssml: "Say yes to start a new game, or no to end the game." + - response.shouldEndSession: false + - sessionAttributes.gamesPlayed: 1 + - sessionAttributes.endedSessionCount: 0 + - sessionAttributes.guessNumber: 50 +- no: + - prompt: "Ok, see you next time!" + - sessionAttributes.gamesPlayed: 1 + - sessionAttributes.endedSessionCount: 1 + - sessionAttributes.guessNumber: 50 --- -- test: "Sequence 02. Test scenario: Invoke NumberGuessIntent. Focus on user interaction." +- test: "Sequence 02. Test scenario: Invoke NumberGuessIntent, do not play." - LaunchRequest: - no: - response.outputSpeech.ssml: "Ok, see you next time!" - sessionAttributes.gamesPlayed: 1 - - sessionAttributes.endedSessionCount: 1 + - sessionAttributes.endedSessionCount: 2 # Previous sequence counts as one ended session --- -- test: "Sequence 03. Test scenario: Invoke NumberGuessIntent. Focus on user interaction." +- test: "Sequence 03. Test scenario: Invoke NumberGuessIntent, play and guess several times." - LaunchRequest: - yes: - - response.outputSpeech.ssml === test - response.reprompt.outputSpeech.ssml: "Try saying a number." - response.shouldEndSession: false - sessionAttributes.gamesPlayed: 1 - sessionAttributes.guessNumber: "*" - - sessionAttributes.endedSessionCount: 1 -- 40: - - exit - - response.outputSpeech.ssml == "40 is too low." goto "75" - - response.outputSpeech.ssml == "40 is too high." goto "50" - - response.outputSpeech.ssml == "40 is correct! Would you like to play a new game?" goto "no" + - sessionAttributes.endedSessionCount: 2 +- 30: + - response.outputSpeech.ssml == "30 is too low." goto 60 + - response.outputSpeech.ssml == "30 is correct! Would you like to play a new game?" goto "no" - response.reprompt.outputSpeech.ssml: "Try saying a larger number." - response.reprompt.outputSpeech.ssml: "Try saying a lower number." -- 75: - - response.outputSpeech.ssml == "75 is too high." goto "50" - - response.outputSpeech.ssml == "75 is correct! Would you like to play a new game?" goto "no" +- 60: + - response.outputSpeech.ssml == "60 is too high." goto "50" + - response.outputSpeech.ssml == "60 is correct! Would you like to play a new game?" goto "no" - response.reprompt.outputSpeech.ssml: "Try saying a larger number." - response.reprompt.outputSpeech.ssml: "Try saying a lower number." -- stop: "*" - 50: - response.outputSpeech.ssml == "50 is correct! Would you like to play a new game?" goto "no" - response.reprompt.outputSpeech.ssml: "Try saying a larger number." - response.reprompt.outputSpeech.ssml: "Try saying a lower number." -- stop: "*" - no: - response.outputSpeech.ssml: "Ok, see you next time!" - sessionAttributes.gamesPlayed: 2 - - sessionAttributes.guessNumber: "*" - - sessionAttributes.endedSessionCount: 2 + - sessionAttributes.guessNumber: "50" + - sessionAttributes.endedSessionCount: 3 --- -# It would be great to use some of the values that comes in the response as utterances to improve interaction -- test: "Sequence 04. Test scenario: Invoke NumberGuessIntent and say no" +- test: "Sequence 04. Test scenario: Invoke NumberGuessIntent and ask for help and then stop." - LaunchRequest: -- yes: - - sessionAttributes.guessNumber: 50 -- no: - - response.outputSpeech.ssml: "Ok, see you next time!" - - sessionAttributes.gamesPlayed: 5 - - sessionAttributes.guessNumber: "*" - - sessionAttributes.endedSessionCount: 3 \ No newline at end of file +- help: + - prompt: "I am thinking of a number between zero and one hundred, try to guess and I will tell you if it is higher or lower." + - reprompt: "Try saying a number." + - response.shouldEndSession: false +- stop: + - prompt: "Goodbye!" + +--- +- test: "Sequence 05. Test scenario: Invoke NumberGuessIntent and test ErrorHandler." +- LaunchRequest: +- bananas: + - prompt: "Sorry, I can't understand the command. Please say again." + - reprompt: "Sorry, I can't understand the command. Please say again." +- cancel: + - prompt: "Goodbye!" \ No newline at end of file From 6f654b21f1d51d301f2c959999b15d9127ff0bf4 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Fri, 1 Jun 2018 14:41:18 -0500 Subject: [PATCH 05/12] Updating the header for master branch --- test/en-US.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/test/en-US.yml b/test/en-US.yml index c8779a6..d38101f 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -1,12 +1,11 @@ #===================================================================================================================== -# ██████╗ ███████╗███████╗██████╗ ██████╗ ██╗ ██╗███████╗███╗ ██╗ -# ██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝████╗ ██║ -# ██████╔╝█████╗ ███████╗██████╔╝██║ ██║█████╔╝ █████╗ ██╔██╗ ██║ -# ██╔══██╗██╔══╝ ╚════██║██╔═══╝ ██║ ██║██╔═██╗ ██╔══╝ ██║╚██╗██║ -# ██████╔╝███████╗███████║██║ ╚██████╔╝██║ ██╗███████╗██║ ╚████║ -# ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ +# ______ _ ____ ______ __ _ +# / __/ /__ (_) / / /_ __/__ ___ / /_(_)__ ___ _ +# _\ \/ '_// / / / / / / -_|_- Date: Sat, 2 Jun 2018 13:23:39 -0500 Subject: [PATCH 06/12] Added a couple more tests --- test/en-US.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/en-US.yml b/test/en-US.yml index d38101f..d0342d7 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -88,4 +88,20 @@ configuration: - reprompt: "Try saying a number." - response.shouldEndSession: false - stop: - - prompt: "Goodbye!" \ No newline at end of file + - prompt: "Goodbye!" + +--- +- test: "Sequence 05. Test scenario: Handles SessionEndedRequest" +- LaunchRequest: +- SessionEndedRequest: + - response: undefined + +--- +- test: "Sequence 06. Test scenario: Test a non-number is passed" +- LaunchRequest +- yes +- "Not a number": + - intent: NumberGuessIntent + - slots: + number: hi + - response.outputSpeech.ssml: "Sorry, I didn't get that. Try saying a number." From 6b96aea07e88fd7755b0e5f9d5cc4422a84e13ed Mon Sep 17 00:00:00 2001 From: John Kelvie Date: Sat, 2 Jun 2018 15:41:10 -0500 Subject: [PATCH 07/12] Update en-US.yml --- test/en-US.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/en-US.yml b/test/en-US.yml index d0342d7..2bb0788 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -5,10 +5,13 @@ # /___/_/\_\/_/_/_/ /_/ \__/___/\__/_/_//_/\_, / # /___/ # -# Test type: Unit/Functional/End-to-End/Regression +# Created by Bespoken +# Learn more at https://read.bespoken.io/unit-testing/getting-started/ +# # Skill name: "High Low Game" by Amazon # Test scope: LaunchRequest, NumberGuessIntent, AMAZON.HelpIntent, AMAZON.StopIntent, # AMAZON.CancelIntent, AMAZON.YesIntent, AMAZON.NoIntent +# Description: Tests all intents using - forces the number to always be 50 for simplicity of testing #===================================================================================================================== --- From dc7daea5dcac2fb3cab4787f4e40755787a4cb73 Mon Sep 17 00:00:00 2001 From: John Kelvie Date: Thu, 14 Jun 2018 15:51:19 -0500 Subject: [PATCH 08/12] FixIndentation --- test/en-US.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/en-US.yml b/test/en-US.yml index 2bb0788..0d330c8 100644 --- a/test/en-US.yml +++ b/test/en-US.yml @@ -106,5 +106,5 @@ configuration: - "Not a number": - intent: NumberGuessIntent - slots: - number: hi + number: hi - response.outputSpeech.ssml: "Sorry, I didn't get that. Try saying a number." From b1e74567141388007018c0f98eee9298f4d3e320 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Fri, 20 Jul 2018 11:25:14 -0500 Subject: [PATCH 09/12] Updating testing project with latest suggestions from Amazon --- skill-testing.json | 9 ---- test/en-US.yml | 110 --------------------------------------- test/unit/index.test.yml | 105 +++++++++++++++++++++++++++++++++++++ test/unit/readme.md | 46 ++++++++++++++++ test/unit/testing.json | 8 +++ 5 files changed, 159 insertions(+), 119 deletions(-) delete mode 100644 skill-testing.json delete mode 100644 test/en-US.yml create mode 100644 test/unit/index.test.yml create mode 100644 test/unit/readme.md create mode 100644 test/unit/testing.json diff --git a/skill-testing.json b/skill-testing.json deleted file mode 100644 index 7a485c9..0000000 --- a/skill-testing.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "handler": "lambda/custom/index.js", - "locale": "en-US", - "trace": "false", - "jest": { - "silent": true, - "coveragePathIgnorePatterns": [] - } -} \ No newline at end of file diff --git a/test/en-US.yml b/test/en-US.yml deleted file mode 100644 index 0d330c8..0000000 --- a/test/en-US.yml +++ /dev/null @@ -1,110 +0,0 @@ -#===================================================================================================================== -# ______ _ ____ ______ __ _ -# / __/ /__ (_) / / /_ __/__ ___ / /_(_)__ ___ _ -# _\ \/ '_// / / / / / / -_|_- Date: Mon, 17 Sep 2018 16:50:46 -0500 Subject: [PATCH 10/12] Updating project with latest readme.md and minor changes in test script file --- test/unit/index.test.yml | 4 ++-- test/unit/readme.md | 39 +++++++++++++++++++++++---------------- test/unit/testing.json | 2 +- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/test/unit/index.test.yml b/test/unit/index.test.yml index 0fc0de5..c17d9c9 100644 --- a/test/unit/index.test.yml +++ b/test/unit/index.test.yml @@ -87,10 +87,10 @@ configuration: - test: Invoke NumberGuessIntent and ask for help and then stop. - NumberGuessIntent - AMAZON.HelpIntent: - - prompt: I am thinking of a number between zero and one hundred, try to guess and I will tell you if it is higher or lower. + - prompt: I am thinking of a number between zero and one hundred, try to guess it and I will tell you if it is higher or lower. - reprompt: Try saying a number. - response.shouldEndSession: false -- AMAZON.StopIntent: Goodbye! +- AMAZON.StopIntent: Thanks for playing! --- - test: Handles SessionEndedRequest diff --git a/test/unit/readme.md b/test/unit/readme.md index 9d72434..5eef00c 100644 --- a/test/unit/readme.md +++ b/test/unit/readme.md @@ -1,13 +1,21 @@ -## **How to setup and run Unit Test scripts** -To get started, you need to install Bespoken Tools, please follow the next steps: -1. Install Bespoken Tools by running `npm install -g bespoken-tools` on your command line. +## **How to setup and run Unit Tests** + +There are several methods commonly used to test and simulate Alexa skills during the development process. +See the Alexa Cookbook [testing guide](https://github.com/alexa/alexa-cookbook/tree/master/guides/testing) for more details. + +For running formal QA tests, developers can leverage third-party tools that run on standard unit test frameworks like [Jest](https://jestjs.io/) or [Mocha](https://mochajs.org/). + +Here we will focus on running a test suite against your local code project using the Bespoken CLI (`bst`) from [Bespoken](https://bespoken.io). + +To get started, you need to install the Bespoken CLI, please follow the next steps: +1. Install the Bespoken CLI by running `npm install -g bespoken-tools` on your command line. 2. Create the main testing folder. We recommend to name it `test`; it should be under the root of your skill's directory. -3. Create a folder named `unit` under `test\`, this folder will store your unit test script files. +3. Create a folder named `unit` under `test\`, this folder will store your unit test script files. 4. Add the test configuration file `testing.json`. This file should be located under your `test\unit` directory. It might look like this: ```JSON { "handler": "../../src/index.js", - "locale": "de-DE", + "locale": "en-US", "trace": true, "jest": { "silent": false @@ -17,8 +25,8 @@ To get started, you need to install Bespoken Tools, please follow the next steps The most important parameter is the handler where you indicate Bespoken's Skill Tester where the source code of your skill is. These parameters can be overwritten on each test script file under their configuration section. 5. Add your test scripts. We recommend to use next convention when naming your test script files: * If you have only one test script: `index.test.yml` - * If you want to create more than one test script: `functionalityName.test.yml`. - + * If you want to create more than one test script: `functionalityName.test.yml`. + The yml extension indicates this is a YAML file, which is the syntax we use to create test scripts; `test` means that is a unit test script file. A test script looks like this: ```YAML --- @@ -26,21 +34,20 @@ To get started, you need to install Bespoken Tools, please follow the next steps locale: en-US --- # Three dashes start a new YAML document - - test: Launch request, no further interaction. # Some metadata about this test sequence - - LaunchRequest: # LaunchRequest is not an utterance but a request type and reserved word + - test: Launch request, no further interaction. # A description of this test sequence + - LaunchRequest: # LaunchRequest is not an utterance but a request type - response.outputSpeech.ssml: Here's your fact - response.card.type: Simple - response.card.title: Space Facts - - response.card.content: "*" # Any text will match + - response.card.content: "*" # A wildcard means any text will match ``` A typical YAML sentence is composed of 2 parts separated by a colon; in the left part we have the intent name we want to test; in the right part we have the expected result. You can also access any element on the JSON response object like the session attributes. 6. To execute the scripts go to the root of your project and run `bst test`. That will find and run all the unit test scripts files. -For more information about skill unit testing please read [here](https://read.bespoken.io/unit-testing/getting-started/). +For more information about skill unit testing with Bespoken, please read [here](https://read.bespoken.io/unit-testing/getting-started/). -If you need assistance, reach us on any of these channels: -* [Chat with us](https://apps.bespoken.io/dashboard) (lower right-hand corner of the page) -* [Email](mailto:contact@bespoken.io) -* [Slack](http://www.alexaslack.com/) +If you need assistance, reach Bespoken on any of these channels: +* [Chat with us](https://bespoken.io/testing) (chat is in lower right-hand corner of the page) +* [Email](mailto:support@bespoken.io) * [Twitter](https://twitter.com/bespokenio) -* [Gitter](https://gitter.im/bespoken) \ No newline at end of file +* [Gitter](https://gitter.im/bespoken) diff --git a/test/unit/testing.json b/test/unit/testing.json index 2730d6d..7943227 100644 --- a/test/unit/testing.json +++ b/test/unit/testing.json @@ -1,6 +1,6 @@ { "handler": "../../lambda/custom/index.js", - "trace": false, + "trace": true, "jest": { "silent": false, "coveragePathIgnorePatterns": [] From 8c976784f50687ec2ca997b9f186a73bc4f94d33 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 17 Sep 2018 18:05:20 -0500 Subject: [PATCH 11/12] Setting trace to false --- test/unit/testing.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/testing.json b/test/unit/testing.json index 7943227..2730d6d 100644 --- a/test/unit/testing.json +++ b/test/unit/testing.json @@ -1,6 +1,6 @@ { "handler": "../../lambda/custom/index.js", - "trace": true, + "trace": false, "jest": { "silent": false, "coveragePathIgnorePatterns": [] From 9a7f4c9abe732f6d5e06793ebace7f206c75b1bc Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Tue, 18 Sep 2018 13:33:05 -0500 Subject: [PATCH 12/12] Adding fallback intent test sequences --- test/unit/index.test.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/unit/index.test.yml b/test/unit/index.test.yml index c17d9c9..fa7a2a8 100644 --- a/test/unit/index.test.yml +++ b/test/unit/index.test.yml @@ -103,3 +103,23 @@ configuration: - LaunchRequest - AMAZON.YesIntent - NumberGuessIntent number=hi: Sorry, I didn't get that. Try saying a number. + +--- +- test: Handles Fallback intent outside the game +- LaunchRequest +- AMAZON.FallbackIntent: + - prompt: The High Low Game skill can't help you with that. It will come up with a number between 0 and 100 and you try to guess it by saying a number in that range. Would you like to play? + - reprompt: Say yes to start the game or no to quit. + - response.shouldEndSession: false + - sessionAttributes.gameState: ENDED + +--- +- test: Handles Fallback intent during the game +- LaunchRequest +- AMAZON.YesIntent +- AMAZON.FallbackIntent: + - prompt: The High Low Game skill can't help you with that. Try guessing a number between 0 and 100. + - reprompt: Please guess a number between 0 and 100. + - response.shouldEndSession: false + - sessionAttributes.gameState: STARTED + - sessionAttributes.guessNumber: 50 \ No newline at end of file