CatalystCode / alarm-bot-unit-testing

Example bot application with LUIS intents and unit testing
12 stars 3 forks source link

How to testing actual dialogs ? #2

Open rjgmail88 opened 6 years ago

rjgmail88 commented 6 years ago

Hi, I have gone over this example and understood how its nicely doing unite testing as expected. However, I do see it more or less just running the expected array from the files under /dialog-flows with some specific code pattern and not actually testing real dialogs or conversation flow. Ex: I have a bot for meeting scheduling where flow looks like as follows

[
  {
    out: "schedule a meeting"
  },
  {
    in: "Who will be attending?",
  },
  {
    out: "John"
  },
  {
    in: "Do you need any meeting room?"
  }, 
 {
    out: "yes"
  },
  {
    in: "done, I have booked your meeting with John today at 5pm."
  }, 
];

how do I test my dialog if user say 'blah blah' when asked by bot "Who will be attending?" Creating an expected array in /dialog-flows and just running through BotTester doesn't really test BOT logic and code.

morsh commented 6 years ago

Why not try the following:

[
  {
    out: "schedule a meeting"
  },
  {
    in: "Who will be attending?",
  },
  {
    out: "blah blah"
  },
  {
    in: "I didn't understand that"
  }, 
 // and so on
];
rjgmail88 commented 6 years ago

Hey, as I said it's not going to test actual logic to determine if "blah blah" is person name. Its purely write your expected and unexpected array & BotTester to process your test array and no logical testing. In my case when user says 'John' I am using MS graph to resolved it to my closest John in the network.

rjgmail88 commented 6 years ago

@morsh , Is this project just about unit testing of alarm-bot ? or this project does have alarm-bot capabilities along with unit testing ? I'm confused because I looked in bot.js which has real dialogs like help, set_alarm and are you unite testing those with arrays from [../dialog/flows..] directories.

Sorry If I'm unclear but in my project I have a following dialog which is triggered by LUIS.

var builder = require('botbuilder');

module.exports = function(bot) {
    bot.dialog('Help', function (session) {
        builder.Prompts.text(session, `I can help you to schedule a meeting, reschedule or cancel 
 existing);

        session.endDialog(); 
    }).triggerAction({
        matches: 'Help'
    });
}

in order to follow according to alarm-bot-unit-testing I had to create bot.js and recreate same dialog in bot.js. even though my projects existing app.js file has all root dialogs,cortana default dialogs etc. So I wonder if bot.js from alarm-bot-unit-testing is actually a test dialog file.

morsh commented 6 years ago

@rjgmail88 - in order to test the dialog, you need to abstract the dialog logic from the code connecting this logic to the bot framework service. For this you need to implement an app.js + bot.js in a similar way like the sample. Notice: this is an old sample using botbuilder version < 4.0, and is mainly used as a reference on how to add unit tests to a bot application.

rjgmail88 commented 6 years ago

Thanks @morsh . Do you have any latest example anywhere I can refer to. I implemented my testing same was as this project does but, i feel LUIS mock isnt working. My test runs even though I comment luis-mock.js file.

morsh commented 6 years ago

@rjgmail88 - sorry, but I don't know any other repos/articles regarding testing of bots.

rjgmail88 commented 5 years ago

@morsh, do you have or know any similar testing capabilities for botbuilder v4 nodejs sdk ? I am looking for writing some unit tests for dialogs for my bot built in v4 node sdk.

morsh commented 5 years ago

@rjgmail88 - sorry, but I no longer maintain this repo