1 /* 2 * Copyright (c) 2017 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.bugs; 6 7 import org.junit.Test; 8 import org.mockito.ArgumentCaptor; 9 import org.mockitousage.IMethods; 10 11 import static org.assertj.core.api.Assertions.assertThat; 12 import static org.mockito.Mockito.mock; 13 import static org.mockito.Mockito.times; 14 import static org.mockito.Mockito.verify; 15 16 public class ArgumentCaptorDontCapturePreviouslyVerifiedTest { 17 @Test 18 public void previous_verified_invocation_should_still_capture_args() { 19 IMethods mock = mock(IMethods.class); 20 21 mock.oneArg("first"); 22 ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class); 23 verify(mock, times(1)).oneArg(argument.capture()); 24 assertThat(argument.getAllValues()).hasSize(1); 25 26 // additional interactions 27 mock.oneArg("second"); 28 argument = ArgumentCaptor.forClass(String.class); 29 verify(mock, times(2)).oneArg(argument.capture()); 30 assertThat(argument.getAllValues()).hasSize(2); 31 } 32 } 33