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.stacktrace; 7 8 import org.junit.Test; 9 import org.mockito.Mock; 10 import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent; 11 import org.mockitousage.IMethods; 12 import org.mockitoutil.TestBase; 13 14 import static junit.framework.TestCase.fail; 15 import static org.assertj.core.api.Assertions.assertThat; 16 import static org.mockito.Mockito.times; 17 import static org.mockito.Mockito.verify; 18 19 public class ClickableStackTracesTest extends TestBase { 20 21 @Mock private IMethods mock; 22 23 private void callMethodOnMock(String param) { 24 mock.simpleMethod(param); 25 } 26 27 private void verifyTheMock(int times, String param) { 28 verify(mock, times(times)).simpleMethod(param); 29 } 30 31 @Test 32 public void shouldShowActualAndExpectedWhenArgumentsAreDifferent() { 33 callMethodOnMock("foo"); 34 try { 35 verifyTheMock(1, "not foo"); 36 fail(); 37 } catch (ArgumentsAreDifferent e) { 38 assertThat(e).hasMessageContaining("callMethodOnMock(").hasMessageContaining("verifyTheMock("); 39 } 40 } 41 } 42