microsoftly / BotTester

A simple bot testing framework for the bot builder framework. Easily send messages to a bot and check for expected responses and inspect session inside a dialog
MIT License
57 stars 11 forks source link

Test dialogs independently #68

Open ihachani opened 6 years ago

ihachani commented 6 years ago

Is there a way to test Library without having to create a bot around it?

https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.library.html

microsoftly commented 6 years ago

No, the framework requires a bot through which it can send and receive messages. You can make a simple bot that allows full logical and code coverage for your library though and test through that.

ihachani commented 6 years ago

Can some one add this? That would save some effort.

microsoftly commented 6 years ago

Now that you mention it, this seems like it may be a useful feature. It would also be cool to setup mock data to preload with. So something like

new BotTester(bot)
    .WithDialog(dialog, <something here to set mock state when dialog starts>)
    .WithMiddleware(middleware)

Would you be interested in helping design the feature &/or the implementation?

ihachani commented 6 years ago

What I did to test the library was create a Bot then mapped the library default Dialog to the bot default Dialog.

let bot = new botbuilder.UniversalBot(new TestConnector());
let library = CustomLibrary.createLibrary();
bot.library(library);
bot.dialog('/', library.dialog('/'));

I am thinking something like this will be helpful:

new BotTester(bot)
    .WithDialog(['/',library.dialog('/')],['greeting', anotherDialog]);
microsoftly commented 6 years ago

I think that would be a great addition. Would you be interested in being a contributor? It will help shape the library towards your needs.

ihachani commented 6 years ago

I will give it a try. Do you have some guidelines?

microsoftly commented 6 years ago