|
|
|
|
|
by simonw
1834 days ago
|
|
I avoid writing automated tests that hit an external API - especially one out of my control - because I don't want my CI runs to ever fail because someone else's service wasn't responding. I want CI to be a completely closed box, such that any failures mean there's a bug in my code. If I want to test external APIs I'll do that in a separate set of integration tests which are run as part of a separate system, not as part of my CI for every code commit to my repo. I mostly use Python, and the APIs I talk to are mostly accessed via the requests or httpx libraries - both of which have excellent libraries for productive mocking: - https://requests-mock.readthedocs.io/en/latest/pytest.html - https://github.com/Colin-b/pytest_httpx |
|