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

Improving Testability of Handlers v2 #111

Merged
merged 34 commits into from
Apr 11, 2020

Conversation

NateBarnes
Copy link
Member

@NateBarnes NateBarnes commented Apr 8, 2020

Ok, here's v2 of the work to improve the testability of handlers. This extracts the Outbound functions of the chat backend into a behaviour, then implements that behavior into a SlackOutbound module. This allows us to create a Spy of this Behaviour to capture outbound replies. I've updated the internal tests of the handler helpers, and then added a few tests for some of the internal handlers to reflect the new style. I've also created some macros to make it easier for people to implement the most common flows in by using Alice.Handlers.Case.

I also updated alice_roller in a separate branch so you can see what tests look like in a third party handler as well: https://github.com/NateBarnes/alice_roller/blob/testing-refactor/test/alice/handlers/roller_test.exs

I believe this should resolve #47 . Let me know what y'all think though

@NateBarnes NateBarnes marked this pull request as draft April 10, 2020 19:28
@NateBarnes NateBarnes marked this pull request as ready for review April 11, 2020 01:46
Copy link
Member

@adamzaninovich adamzaninovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how this turned out! Can't wait to use it to actually test all these handlers with zero coverage!

Here are a few things I saw.

test/support/case.ex Outdated Show resolved Hide resolved
test/alice/router/helpers_test.exs Outdated Show resolved Hide resolved
test/support/case.ex Outdated Show resolved Hide resolved
test/support/case.ex Outdated Show resolved Hide resolved
test/support/case.ex Outdated Show resolved Hide resolved
mix.lock Outdated Show resolved Hide resolved
test/support/case.ex Outdated Show resolved Hide resolved
NateBarnes and others added 5 commits April 11, 2020 07:31
Co-Authored-By: Adam Zaninovich <adam.zaninovich@gmail.com>
Co-Authored-By: Adam Zaninovich <adam.zaninovich@gmail.com>
Co-Authored-By: Adam Zaninovich <adam.zaninovich@gmail.com>
Copy link
Member

@adamzaninovich adamzaninovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to run the formatter, but other than that it looks good to me.

@NateBarnes
Copy link
Member Author

Ok, formatter has been run, ran credo while I was at it, and wrote a bunch of documentation for the new modules and methods.

Copy link
Member

@adamzaninovich adamzaninovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@adamzaninovich adamzaninovich merged commit 967c7e2 into alice-bot:master Apr 11, 2020
@NateBarnes NateBarnes deleted the testing-handlers branch April 11, 2020 17:52
@tielur
Copy link
Member

tielur commented Apr 13, 2020

❤️

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 this pull request may close these issues.

Make it easier to test handlers
3 participants