use of org.mockito.stubbing.VoidAnswer1 in project mockito by mockito.
the class StubbingWithAdditionalAnswersTest method will_execute_a_void_based_on_strongly_typed_one_parameter_function.
@Test
public void will_execute_a_void_based_on_strongly_typed_one_parameter_function() throws Exception {
final IMethods target = mock(IMethods.class);
given(iMethods.simpleMethod(anyString())).will(answerVoid(new VoidAnswer1<String>() {
public void answer(String s) {
target.simpleMethod(s);
}
}));
// invoke on iMethods
iMethods.simpleMethod("string");
// expect the answer to write correctly to "target"
verify(target, times(1)).simpleMethod("string");
}
Aggregations