Skip to content
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

Define and document testing patterns for scripts #985

Closed
michaelansel opened this issue Jun 18, 2015 · 9 comments · Fixed by hubotio/generator-hubot#61
Closed

Define and document testing patterns for scripts #985

michaelansel opened this issue Jun 18, 2015 · 9 comments · Fixed by hubotio/generator-hubot#61

Comments

@michaelansel
Copy link
Collaborator

Unit testing of scripts is pretty poor right now and there is no recommendation in the documentation on how testing should be done.

There are some thoughts in #873 about a new script pattern that might better enable testing.

We need a pattern that enables both unit testing of script components and functional testing of the overall script. It would be nice if functional tests could be reused by a larger test harness.

Some code that looks useful:
https://github.com/mtsmfm/hubot-test-helper
https://github.com/blalor/hubot-mock-adapter

Once a pattern gets figured out, we should bake it into the generator.

@michaelansel michaelansel changed the title Document testing patterns for scripts Define and document testing patterns for scripts Jun 18, 2015
@michaelansel
Copy link
Collaborator Author

Whoops, completely forgot about hubotio/generator-hubot#45

@technicalpickles
Copy link
Member

💯 ❌ 👍

I've mentioned elsewhere we're using the hubot-mock-adapter, with some helpers. It's a pretty simple framework on top of it, so probably can be extracted. Here's an example script with test and the helper: https://gist.github.com/technicalpickles/971b40520fb8db63a6f4

@ghostsquad
Copy link

💯 👍 This is very much needed. I don't think I can even use Hubot for all the things I want to do, because it is difficult/convoluted to try to test it. These workflows include:

Incoming webhook -> Channel message or attachment
Incoming webhook -> Private message
Incoming webhook -> private/public message -> Outgoing webhook
private/public message -> Outgoing webhook

I think it might just be easier to make my own smaller bot. It won't do as much or have access to all the community scripts (without porting them), but at the same time, it doesn't need to.

I've read up on the hubot-test-helper and hubot-mock-adapter.

@mdelagrange
Copy link

I was recently upgrading our Hubot instance and tests, and https://github.com/mtsmfm/hubot-test-helper worked great! So far it's the only working test framework I've found. I wrote an article about it here.

@michaelansel
Copy link
Collaborator Author

@mdelagrange I think you mixed up your links. You double linked to the GitHub repo. Looking forward to reading the article!

@mdelagrange
Copy link

Oops, thanks @michaelansel. Fixed!

@michaelansel
Copy link
Collaborator Author

Excellent writeup! Hopefully that can get people building some form of tests until we develop an official pattern (unless you would like to do that! 😉)

@mdelagrange
Copy link

I'd love to take a crack at it. I'll give it a go soon.

mdelagrange pushed a commit to mdelagrange/generator-hubot that referenced this issue Dec 4, 2015
Starting to fix hubotio/hubot#985 by adding hubot-test-helper from @mtsmfm
to the script template
@mdelagrange
Copy link

I have a couple of pull requests open for Hubot testing patterns. hubotio/generator-hubot#61 adds testing of Hubot responses to the script generator, and #1094 shows sample tests for the default script from the robot generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants