Throw exception
Closed this issue · 3 comments
sw-tracker commented
Hi there,
I would like to throw an exception when httpClient.newCall(request).execute()
runs as part of my unit tests. How can I do this with your mock?
Cheers,
Olga
gmazzo commented
You can archive that with the RuleAnswer
pattern:
rule(get) {
respond { throw IllegalStateException("an IO error") }
}
sw-tracker commented
and in java?
gmazzo commented
In java will be:
interceptor.addRule()
.answer(request -> throw new IllegalStateException("an IO error"))