-
Notifications
You must be signed in to change notification settings - Fork 981
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
Test friction #1559
Comments
Hi @sammyhenningsson, this is actually a great question!
However as you rightly pointed out, this isn't easy when you're developing a client, because that would require some sort of dependency injection, which would cause the test code to differ from the one used in production. To be fair, I believe the test adapter is more suited to write tests for middleware, not for API clients like the one you're building. I also build lots of those and in my experience there are 2 main ways to write tests for these:
Personally, I prefer the former for a variety of reasons, but I also know plenty of people who prefer the latter. I should probably update the docs to formalise this advice, but interested in your feedback before I do that 🙂 |
Thank you for this explanation! |
Basic Info
Issue description
I find it painful to test code using Faraday. I'm wondering if it would be possible to improve the testing experience. Or please give me suggestions if I can improve my usage of Faraday.
Typically will write clients that uses Faraday internally. For example:
I don't understand how I should stub requests that such a client makes. From the documentation, its says that stubbing should be done when initializing a Faraday::Connection. But (at least the way I write my clients), I don't have control over these internals and I would like a more "global" way of stubbing requests.
Do you think there's any way this can be done/improved?
Or do you have any suggestion for improving the way I design my clients?
The text was updated successfully, but these errors were encountered: