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

Create Unit Tests #11

Closed
rgomez90 opened this issue Oct 18, 2018 · 12 comments
Closed

Create Unit Tests #11

rgomez90 opened this issue Oct 18, 2018 · 12 comments

Comments

@rgomez90
Copy link
Collaborator

This repo needs some tests to assure it works as wished 😄

@PromoFaux
Copy link
Owner

Very agree with that. I'm a terrible dev insofar as I never learned to write testable code! All a bit "new fangled" for my experience ;) this project feels like a good fit to start learning, however :)

@cindra10
Copy link

Hi everyone,
I would like to give this a shot.
Would it be ok to provide a webhook URL from the app.config since the webhook endpoint should be kept secret?
Are there any specific cases you would like to be covered?

@PromoFaux
Copy link
Owner

Feel free to give it a shot! I think I could probably stand to learn a thing or two myself.

RE: Webhook URL. That raises an interesting point. In order to test this library, are we going to need an available endpoint for it to ping? I would have thought the tests would need to be self-contained, and not rely on a (potentially unavailable) external source.

Then again, I have no idea what I'm talking about when it comes to tests so... 🤷‍♂️

@cindra10
Copy link

Tests should be mocked but I've never done any HTTP related testing and this was the first idea I've had. I could do some research on this topic later today.

@PromoFaux
Copy link
Owner

Just going to drop this here to remember to read it later:

https://github.com/WireMock-Net/WireMock.Net

@fluffynuts
Copy link

@cindra10 if you can inject a url for the endpoints you want to hit, check out nuget package PeanutButter.SimpleHttpServer -- check out the tests here for usage. Happy hacking (:

@rgomez90
Copy link
Collaborator Author

@PromoFaux , @cindra10 AFAIK unit tests SHOULD be self-contained. You should not hit any real endpoint in unit tests, that's the case for integration tests. I never tested http methods, but I heard about mocking HttpMessageHandler.

@rgomez90
Copy link
Collaborator Author

rgomez90 commented Oct 23, 2018

After reading a while, a possible solution would be to mock (using Moq) HttpMessageHandler to return a OK response that contains the json we sent. This way we could test if the json looks like it should.

Here the article

@cindra10
Copy link

@rgomez90 You are correct, I was too tired when I initialy responded to this so we can kind of ignore previous replies 😄. I've taken a look at both proposed packages (by @PromoFaux and @fluffynuts), both are relatively easy to setup . Other than that I didn't have much time to investigate, I will take a look at the article you linked ASAP.

@rgomez90
Copy link
Collaborator Author

hey @cindra10 😄 are you working / gonna work on it at the end?

@cindra10
Copy link

Hi @rgomez90 sorry but I simply can't find time to work on anything currently, college and work are just taking too much effort 😞. Since I'd still like to learn a few things about testing HTTP related projects, could you please let me know when these are implemented so I can take a look? :)

@rgomez90
Copy link
Collaborator Author

First goes first @cindra10!! Thanks for the quick response! 😄 Sure! We'll let you know once implemented!

@PromoFaux PromoFaux added this to the 1.5 milestone Oct 31, 2018
@PromoFaux PromoFaux moved this from todo to done in v1.5 Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v1.5
done
Development

No branches or pull requests

4 participants