1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 6 package org.mockitousage.bugs; 7 8 import org.junit.Test; 9 import org.mockito.ArgumentCaptor; 10 import org.mockito.Mock; 11 import org.mockitousage.IMethods; 12 import org.mockitoutil.TestBase; 13 14 import static junit.framework.TestCase.assertEquals; 15 import static org.mockito.Mockito.only; 16 import static org.mockito.Mockito.verify; 17 18 //bug 197 19 public class ShouldOnlyModeAllowCapturingArgumentsTest extends TestBase { 20 21 @Mock IMethods mock; 22 23 @Test shouldAllowCapturingArguments()24 public void shouldAllowCapturingArguments() { 25 //given 26 mock.simpleMethod("o"); 27 ArgumentCaptor<String> arg = ArgumentCaptor.forClass(String.class); 28 29 //when 30 verify(mock, only()).simpleMethod(arg.capture()); 31 32 //then 33 assertEquals("o", arg.getValue()); 34 } 35 } 36