Reputation: 141
I am trying to set up unit-tests in my code wherein I would like to mock the rest calls going to an external web service. I know a couple of ways to do so:
Stub the methods that make the call to external webservice using PowerMock to return mock response objects.
For unit tests, change the host address of the web service to point to localhost and then use the WireMock to attach to localhost and send out responses.
What I want to do is not change the host address in (2) and let WireMock (or any other third party library) intercept the call to a given host and based on the call send out the response.
In other words, I would like to configure WireMock in such a way that if my code is calling for instance http://www.google.com then WireMock will intercept that call and respond with something I configure. (Basically stub www.google.com).
Upvotes: 1
Views: 2346
Reputation: 4149
Unfortunately WireMock can't do this.
You have a three options (that I can think of):
Upvotes: 1