Below are a few suggestions to help with testing the bot's code before doing any front-end testing. A big key to do this type of testing is to have the developer be neat and consistent with their coding. If the code is very messy or the developer is not consistent, this process may not work.
Before beginning, make sure to have a text editor that allows line sorting and a mode that allows the selection of text in columns.
- For Notepad++
- Line sorting is under Edit → Line Operations → Sort Line Lexicographically Ascending
- Column Mode is under Edit → Column Mode or hold down the Alt key as you select text with the mouse.
- For Notepad++
Check for correct messaging
- What is being done here
- Making sure the correct messages are given.
- Making sure messages are given in the correct order.
- Making sure Action names are correct
- Steps:
- Open bot in Azure Health Bot editor
- Go to Code view
- Click in code area and hit Ctrl-A to select all of the code
- Hit Ctrl-C to copy the code
- Open a new file in the text editor and hit Ctrl-P to paste the code
- Sort the lines of code. This will group similar lines of code together.
- Scroll down to the lines that begin with "label".
- Here you will find lines that include the Message IDs.
- These are the labels for the Action items.
- Delete all the lines above these lines and any lines in between the lines we care about.
- Scroll down to the lines that begin with "onInit".
- Here you will find lines that contain the Message IDs.
- These contain the code found inside of the action items.
- Delete all the lines below these lines.
- Delete all the lines between the "label" lines you care about and the "onInit" lines you care about.
- What is left should look similar to this:
- Using the Column Mode feature, remove the ""label": "" and the ""onInit": "scenario.outcomeID = '" text from the front of these lines.
- What is left should look like this:
- Sort the lines of code.
- What is left should look like this:
- Note that the test from the "label" lines are now next to the text of the corresponding "onInit" lines.
- Now review the code to make sure the Message IDs match, the label text is correct, the correct messages are given and the messages are given in the correct order.
- Tips:
- Compare the message given and their order to the bot's documentation. As a line is verified, either mark it some way in the text editor or delete the line from the text editor document.
- All of this should be done inside a text editor. DO NOT DO ANY EDITING INSIDE THE CODE VIEWER OF THE AZURE HEALTHBOT APP!!!!
- Open bot in Azure Health Bot editor
Check for correct Outcome code
- What is being done here:
- Comparing Outcome code to make sure all variables are being used
- Comparing Outcome code to make sure the code matches correctly (for those blocks that should match)
- Looking for anything that looks off in the code
- Steps:
- Open bot in Azure Health Bot editor
- Go to Code view
- Click in code area and hit Ctrl-A to select all of the code
- Hit Ctrl-C to copy the code
- Open a new file in the text editor and hit Ctrl-P to paste the code
- Do this for all bots that are part of the same project. All code goes into separate documents in the text editor.
- Sort the lines of code in each document. This will group similar lines of code together.
- Look for the Outcome code. This will be in the area of the code that begins with "onInit". You may need to look at the code in the Action items in the bot diagram to see what you are looking for. Depending on how the bot is written, there could be multiple Outcome code lines.
- Once found, delete all the line except for these lines.
- Do this for each document in the text editor containing code.
- The next step is to combine all of these lines into a single document. Before doing this make sure to add a marker at the beginning of each line to identify which bot code it came from. This is very important otherwise once all the code is in a single document, it will be hard to find which bot it came from.
- Once the lines of code are combined in a single document, it should look similar to this:
- If the developer was neat and consistent, hopefully the code will line up. Review the code and look for anything that seems out of place. Note how in the below image the alignment is off. In this case this is pointing to an error in that misaligned code line.
- Open bot in Azure Health Bot editor