I am using okhttp to mock my http responses during my tests.
//Create a mock server
mockWebServer.start(8080)
mockWebServer.enqueue(MockResponse().setBody("").setResponseCode(HttpURLConnection.HTTP_OK))
However, this responds to every path as OK.
How do I mock a specific url instead of all of them?
Using Dispatcher
Above can be written inside your test method. You can have a bunch of URLs conditions there.
The mockwebserver can be started once like:
Use
@DynamicPropertySource
to change any property with mockserver host/port.