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.Mock; 10 import org.mockito.exceptions.verification.NeverWantedButInvoked; 11 import org.mockitousage.IMethods; 12 import org.mockitoutil.TestBase; 13 14 import static org.junit.Assert.fail; 15 import static org.mockito.Mockito.*; 16 17 //see bug 138 18 public class VerifyingWithAnExtraCallToADifferentMockTest extends TestBase { 19 20 @Mock IMethods mock; 21 @Mock IMethods mockTwo; 22 23 @Test shouldAllowVerifyingWhenOtherMockCallIsInTheSameLine()24 public void shouldAllowVerifyingWhenOtherMockCallIsInTheSameLine() { 25 //given 26 when(mock.otherMethod()).thenReturn("foo"); 27 28 //when 29 mockTwo.simpleMethod("foo"); 30 31 //then 32 verify(mockTwo).simpleMethod(mock.otherMethod()); 33 try { 34 verify(mockTwo, never()).simpleMethod(mock.otherMethod()); 35 fail(); 36 } catch (NeverWantedButInvoked e) {} 37 } 38 } 39