• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.mockitousage.bugs;
2 
3 import org.junit.Test;
4 import org.mockito.ArgumentCaptor;
5 import org.mockitousage.IMethods;
6 
7 import static org.assertj.core.api.Assertions.assertThat;
8 import static org.mockito.Mockito.mock;
9 import static org.mockito.Mockito.times;
10 import static org.mockito.Mockito.verify;
11 
12 public class ArgumentCaptorDontCapturePreviouslyVerifiedTest {
13     @Test
previous_verified_invocation_should_still_capture_args()14     public void previous_verified_invocation_should_still_capture_args() {
15         IMethods mock = mock(IMethods.class);
16 
17         mock.oneArg("first");
18         ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
19         verify(mock, times(1)).oneArg(argument.capture());
20         assertThat(argument.getAllValues()).hasSize(1);
21 
22         // additional interactions
23         mock.oneArg("second");
24         argument = ArgumentCaptor.forClass(String.class);
25         verify(mock, times(2)).oneArg(argument.capture());
26         assertThat(argument.getAllValues()).hasSize(2);
27     }
28 }
29