-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this framework for unit test only? #48
Comments
@pradgnyak this can test any bot in any environment. I'm not sure what your question is. I'd be happy to give more insight if you want it |
I have installed the package and set the Config File
My Test Filevar botbuilder = require('botbuilder');
var IAddress = require('botbuilder').IAddress;
var IMessage = require('botbuilder').IMessage;
var Message = require('botbuilder').Message;
var Prompts = require('botbuilder').Prompts;
var Session = require('botbuilder').Session;
var UniversalBot = require('botbuilder').UniversalBot;
var botTester = require('bot-tester');
// import { IAddress, IMessage, Message, Prompts, Session, UniversalBot } from 'botbuilder';
require('chai');
require('mocha');
var expect = require('chai').describe;
// import { BotTester, TestConnector } from 'bot-tester';
// import { getAdaptiveCard, getAdaptiveCardAttachment, getAdaptiveCardMessage } from './adaptiveCardProvider';
// import { read } from 'fs';
const connector = new botTester.TestConnector();
describe('BotTester', () => {
var bot;
beforeEach(() => {
// bot = new UniversalBot(connector);
// var connector = new botbuilder.ChatConnector({
// appId: 'XXXXXXX',
// appPassword:XX'
// })
var connector = new botTester.TestConnector();
// connector.listen();
bot = new UniversalBot(connector);
console.log(bot);
});
it('can handle a single response', () => {
bot.dialog('/', (session) => {
session.send('hi!');
});
var bt = new botTester.BotTester(bot)
.sendMessageToBot('Hola!', 'hi!');
return bt.runTest();
});
}); Result> mocha test1
0 passing (37ms)
1 failing
1) BotTester
can handle a single response:
Error: the string "timedout while waiting to receive [\n \"hi!\"\n]" was thrown, throw an Error :)
at tryCatcher (node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/release/async.js:17:14) |
Could you please format your submission and tidy up the code a tad? I'm having some trouble following what you did |
what version of the |
Updated the comment. |
Great catch. Looks like something is wrong with the timeout when it's not set in the config file. I'll have another release out soon to resolve the issue. In the meantime, let me know if throwing in a |
I had tried it with timeout too but it resulted in same error. |
here's the file I'm running (same as yours, fluff removed) var botTester = require('bot-tester');
var botbuilder = require('botbuilder');
var UniversalBot = botbuilder.UniversalBot;
require('chai');
require('mocha');
const connector = new botTester.TestConnector();
describe('BotTester', () => {
var bot;
beforeEach(() => {
var connector = new botTester.TestConnector();
bot = new UniversalBot(connector);
});
it('can handle a single response', () => {
bot.dialog('/', (session) => {
session.send('hi!');
});
return new botTester.BotTester(bot)
.sendMessageToBot('Hola!', 'hi!')
.runTest();
});
}); and the {
"timeout":1000,
"defaultAddress": {
"id": "XXXXXXX",
"channelId": "console",
"bot": {
"id": "XXXXXX:XXXXXX",
"name": "mwtest_bot"
},
"user": {
"id": "XXXXX:XXXXX",
"name": "mwtest"
},
"conversation": {
"id": "XXX;XXXX;XXX",
"name": "directmessage"
}
}
} and the {
"defaultAddress": {
"id": "XXXXXXX",
"channelId": "console",
"bot": {
"id": "XXXXXX:XXXXXX",
"name": "mwtest_bot"
},
"user": {
"id": "XXXXX:XXXXX",
"name": "mwtest"
},
"conversation": {
"id": "XXX;XXXX;XXX",
"name": "directmessage"
}
}
} The error message I'm is exactly the same as the one you're getting: |
Test passes after adding the timeout, but I do not see the interaction on my slack. Where is this request going? |
When you say you don't see the interaction on your slack, what are you expecting to see?
The behavior I would expect is only having bot responses being seen on the slack channel. I personally have not tested with a bot out in the wild. I'm unsure why the messages would not be sent properly. Is no request being sent out? Can you take a snapshot of the messages you're attempting to send? Try attaching an outgoing listener and see what's actually being sent. Also try with the ConsoleConnector to see if the messages are printed to the console |
My test case is Is there a detailed documentation of all the available methods? |
I think the answer you're looking for is:
A possible feature request could be adding functions like The detailed docs for sendMessageToBot documentation can be found in the BotTester Framework Docs. It gives a full type definitions along with any typedocs associated with methods, fields, or classes. As a final note: unless your bot acts differently for messages from slack than it would from other channels, I would recommend you reconsider how you're testing or viewing your testing altogether. This framework is can test a bot in any environment, but only simulate receiving messages (I'm still unsure if it would actually send them out seeing because outgoing message's destination channel shouldn't exist). tldr; as of this writing, this is good for unit to integration/component level testing for the bot itself, though you can test in any environment. You can choose to mock external dependencies/requests or let them through to a live system, but the messages to the bot will always be mocked/simulated |
@pradgnyak let me know if this helped or there is more clarity you need. I'd be happy to work with you and extend the existing functionality to suit your needs |
Thanks a lot, we have decided to use slack API's for testing since they are exposed and can be used for end to end testing in real environment. If we change our approach I will get in touch with you. |
This doesn't test actual apps?
The text was updated successfully, but these errors were encountered: