
Ask HN: How do you mock a 3rd party REST server? - billconan
Hello,<p>I&#x27;m making a github integration, so I rely on github&#x27;s rest api on my backend.<p>I wonder how I can do unit tests for my backend by mocking github&#x27;s api?<p>What method do you recommend?<p>Thanks
======
adamb_
If you've built a wrapper around the integration in your application logic --
such that handling the actual HTTP requests has been abstracted away from the
rest of your application -- then you can use a mocking framework (like Mockito
for Java) directly in the unit tests. If you haven't, or want higher-level /
isolated integration testing, you can create a mock application that mimics
GitHub's API, put it in a Docker container, and use a docker-compose.yml
during testing to quickly spin up your new test environment.

