java - why my unit test failing after adding a parameter? -
here code when working fine
verify(loginservice).getuser(eq(loginname)); here failing..
@test public void test_getuserflow4() { ... loginmodel loginmodelreturned = loginservice.getuser(loginname, null); assertgeneralconditions(loginmodelreturned); ... } private void assertgeneralconditions(loginmodel loginmodelreturned){ verify(loginservice).getuser(eq(loginname), null); //test failed here other lines not executed .... .... } here getuser method
public loginmodel getuser(string loginname, string useragent) { // useragent not being used anywhere .... return model; } exact error:
org.mockito.exceptions.misusing.invaliduseofmatchersexception: invalid use of argument matchers! 2 matchers expected, 1 recorded:
if you're using argument matches, need use them all arguments. fix test, can use:
verify(loginservice).getuser(eq(loginname), matchers.<string>eq(null)); or:
verify(loginservice).getuser(eq(loginname), (string) isnull()); or personally, i'd clarify having useragent variable value of null:
string useragent = null; verify(loginservice).getuser(eq(loginname), eq(useragent));
Comments
Post a Comment