java - Using mockito with wildcard agruments -
i trying pass wildcard mockito any() method. method
selectgatewayinfoconfig(operation<?> o)
what trying is:
when(gatewayconfigselector.selectgatewayinfoconfig( any(**!!!!!! here need wildcard !!!!**)); .thenreturn(...something...);
thanks in advance.
how about?
when(gatewayconfigselector.selectgatewayinfoconfig( any(operation.class)); .thenreturn(...something...);
example:
@test public void test() { tester mock = mockito.mock(tester.class); mockito.when(mock.selectgatewayinfoconfig(mockito.any(operation.class))).thenreturn("blah"); system.out.println(mock.selectgatewayinfoconfig(null)); } class operation<t> { } class tester { public string selectgatewayinfoconfig(operation<?> o) { return "hi"; } }
Comments
Post a Comment