Auto testing for Microsoft Bot Framework [closed]

不打扰是莪最后的温柔 提交于 2019-12-19 03:00:16

问题


I'm working now on my first bot with Microsoft Bot Framework, with ASP.NET.

After manually testing with the bot emulator, I'm looking for the best method to create automatic testing for the bot.

Considering two problems:

  1. What is the best tool to automate such tests?
  2. What is the best method to test a dialog that can return different answers to the same input?

回答1:


One alternative is doing functional tests using DirectLine. The caveat is that the bot needs to be hosted but it's powerfull. Check out the AzureBot tests project to see how this works.

Another alternative, is doing what the BotFramework team is doing for some of their unit tests.

If you are using Dialogs, you can take a look to the EchoBot unit tests as they are simple to follow.

If you are using Chain, then take a look to how their are using the AssertScriptAsync method.

  • https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/ChainTests.cs#L360

  • https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/ChainTests.cs#L538

If you are looking for a way to mock up Luis Service, see this.




回答2:


You may want to consider Selenium. Selenium is web browser automation software allowing you to write tests that programmatically read and write to the DOM of a web page. With a Selenium script you can:

  • login on any channel that provides a web client (and most of them do: WebChat, Telegram, Skype, Facebook, for example)
  • start a conversation with your bot
  • perform operations such as post a message to the chat and wait for a reply
  • test whether the reply is what you expected.



回答3:


For automated testing of bots in Node.js, using ConsoleConnector in the same way as the tests in BotBuilder on GitHub works well, e.g. take a look at https://github.com/Microsoft/BotBuilder/blob/master/Node/core/tests/localization.js:

var assert = require('assert');
var builder = require('../');

describe('localization', function() {
this.timeout(5000);
it('should return localized prompt when found', function (done) { 
    var connector = new builder.ConsoleConnector();       
    var bot = new builder.UniversalBot(connector);
    bot.dialog('/', function (session, args) {
        session.send('id1');
    });
    bot.on('send', function (message) {
        assert(message.text === 'index-en1');
        done();
    });
    connector.processMessage('test');
});

...etc...



来源:https://stackoverflow.com/questions/41348791/auto-testing-for-microsoft-bot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!