You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: testing/TestFlow/README.md
+30-13Lines changed: 30 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,19 @@
1
1
## TestFlow <aid="title"></a>
2
2
3
-
In the main [testing](../testing) folder, we see several examples of how to test your code with one specific event.
3
+
Are you developing a conversational skill? Maybe you are building a game, or a questionnaire, that requires several steps.
4
+
You have probably seen how session attributes are set and get to allow the skill to remember things and keep track of the state of the skill.
5
+
Sometimes it is difficult to visualize how your skill behaves as a "state machine" through many sequences of events.
6
+
It can get tedious to verbally test a skill with several steps.
7
+
8
+
In the main [testing](../testing) folder, we see several examples of how to test your code with one specific, discrete event.
4
9
This is useful if you have a specific test state you need to reproduce and debug.
5
10
6
-
Many skills are designed to have a conversation with the user involving multiple steps.
7
11
A skill may prompt the user for inputs early in the conversation, store the responses in session attributes, and use the values to look up data or perform an action.
8
12
Game skills will keep track of user names, current scores, high scores, etc.
9
-
As a developer, in order to visualize the state of session attributes throughout a long skill session, it helps to be able to run a pre-defined sequence of events and observe the state of the attributes at each point.
13
+
As a developer, in order to visualize the state of session attributes throughout a long skill session, it helps to be able to run a pre-defined sequence of events and observe everthing that is happening at each point.
14
+
It is also very useful if you can override the unit test with a custom response, for example to test a multiple-choice quiz game where the correct answer depends on a random question.
10
15
11
-
This tutorial will show you an easy way to define, run, and view test sequences against your skill code.
16
+
This tutorial will show you an easy way to define, run, and view test sequences against your skill code from your local command line.
@@ -21,32 +26,33 @@ This tutorial will show you an easy way to define, run, and view test sequences
21
26
Define a text file with your skill's input events.
22
27
Put one Request or Intent per line. This corresponds to each of the Intent requests your code expects to receive from the Alexa service.
23
28
24
-
For example: *default.txt*
29
+
For example: *dialogs/default.txt*
25
30
26
31
```
27
32
LaunchRequest
28
33
AMAZON.HelpIntent
29
-
AMAZON.CancelIntent
30
34
AMAZON.StopIntent
31
35
```
32
36
33
-
Another example: *staterequest.txt*
37
+
Another example: *dialogs/staterequest.txt*
34
38
35
39
```
36
40
LaunchRequest
37
41
StateRequestIntent usstate=Vermont
38
42
StateRequestIntent usstate=New%20York
39
43
ISeeIntent animal=bear color=brown
40
-
AMAZON.HelpIntent
44
+
# AMAZON.HelpIntent
41
45
AMAZON.StopIntent
42
46
MyNameIsIntent myName=
43
47
MyNameIsIntent myName=Madeline
44
-
StateRequestIntent usstate=Texas
48
+
? StateRequestIntent usstate=Texas
45
49
RecapIntent
46
50
AMAZON.StopIntent
47
51
```
48
52
49
-
Notice that slot values with spaces need to be encoded. Just insert ```%20``` to replace any white spaces, such as in ```usstate=New%20York```
53
+
* Notice that slot values with spaces need to be encoded. Just insert ```%20``` to replace any white spaces, such as in ```usstate=New%20York```
54
+
* You can prompt the user to confirm, or type in, a slot value by adding a leading ```? ``` to your Intent
55
+
* You can comment out a line with a pound #
50
56
51
57
#### Running the test
52
58
@@ -70,10 +76,20 @@ You may change any of these to ```true``` or ```false```.
70
76
constoptions= {
71
77
speechOutput :true, // the cyan text you hear the Echo say
72
78
slots :true, // key/value pairs shown in blue and green
73
-
attributes :true, // session.attributes shown in magenta
79
+
attributes :true, // session.attributes shown in magenta. You can also name one particular attribute to watch instead of the boolean
74
80
stdout :false// console.log() messages or errors, shown in white
81
+
requestEvent :false, // the full request JSON sent to your code
82
+
reprompt :false, // show the reprompt below the speechOutput
83
+
delay :1.0// delay N seconds between requests
75
84
};
76
85
```
86
+
#### AWS Calls
87
+
If your code makes calls to AWS Services such as S3 or IOT, you should be able to test these from your local command prompt, too.
88
+
Be sure you have the AWS CLI (command line interface) [installed](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) and [configured](https://developer.amazon.com/blogs/post/Tx1UE9W1NQ0GYII/publishing-your-skill-code-to-lambda-via-the-command-line-interface).
89
+
90
+
**Note:** the ```alexa-sdk``` feature to automatically persist session attributes to a DynamoDB table has not been successfully tested with TestFlow.
Notice in magenta (purple) the session attributes that store values your skill is designed to remember.
@@ -82,10 +98,11 @@ By default, this object is empty ```{}```
82
98
Each new request uses the session attributes object from the previous session's output.
83
99
The skill code may add or modify the session attributes. Look for any changes in the attributes after each Intent.
84
100
If your skill causes the session to end, such as when an ```AMAZON.StopIntent``` handler calls ```this.emit(':tell' )```, the session attributes will be lost.
85
-
If your skill uses an AWS DynamoDB table, however, you can expect the session attributes to be saved and re-loaded after each session ends, within the actual AWS Lambda environment.
86
101
87
102
88
-
#### Try it on your code
103
+
#### Installation Steps
104
+
To try TestFlow on your own skill code, follow these steps:
105
+
89
106
1. Copy and paste the ```testflow.js``` file and ```/dialogs``` folder to your project folder, next to your ```/src``` folder.
90
107
1. Customize the settings within the top of the ```testflow.js``` file
91
108
1. Create a new dialog sequence file with your Intents in sequence, such as ```mytest.txt```
0 commit comments