mercredi 28 octobre 2020

Stubbing void method using mockito is not working

doThrow(new Exception()).when(service.method(anyString(), anyBoolean(), anyString()));

Does not working because the method returns void.

doThrow(new Exception()).when(service).method(anyString(), anyBoolean(), anyString());

Does not stub properly.

The stubbing is: method("", false, "") instead of createConsent(<any string>, <any bool>, <any string>) and I get a stubbing mismatch

 - this invocation of 'method' method:
    service.method(
    "ad6b9045-e120-44ed-94df-c8262f19409d",
    false,
    "j39fj230jf390j09jf390"
);
    -> at ....java:108)
 - has following stubbing(s) with different arguments:
    1. service.method("", false, "");

What is going on?

Aucun commentaire:

Enregistrer un commentaire