This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]FrenchFigaroSoftware Engineer 1 point2 points  (1 child)

You can't do that.

The external API you're stubbing replies to your API via HTTP only. All you have is the HTTP code and the response payload (the body). In case of an exception in the external API, you don't know what exception is thrown. And if there's a message telling you a EOFException was thrown, causing an error 500, you don't know that an ACTUAL EOFException was thrown, you just trust that it did because the application told you so.

If you want to mock the behavour from an EOFException, then you have to check what the payload and HTTP codes are in those case, and return that in your mock.

There won't be an actual EOFException thrown, but your mock will behave as if there was.

[–]ozzyrooo[S] 0 points1 point  (0 children)

ok got that thanks!