×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Massimo Zappino
Added: Nov 5, 2019 1:08 PM
Views: 4136
  1. MyClass mockClient = mock(MyClass.class);
  2. when(mockClient.isConnected()).thenAnswer(new Answer() {
  3.   private int count = 0;
  4.  
  5.   public Object answer(InvocationOnMock invocation) {
  6.       return count++ > invocationsUntilTrue;
  7.   }
  8. });
  9.