1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.bugs; 6 7 import static org.junit.Assert.fail; 8 import static org.mockito.Mockito.verify; 9 10 import java.util.LinkedList; 11 import java.util.List; 12 13 import org.assertj.core.api.Assertions; 14 import org.junit.Test; 15 import org.mockito.Spy; 16 import org.mockitoutil.TestBase; 17 18 // see issue 216 19 public class SpyShouldHaveNiceNameTest extends TestBase { 20 21 @Spy List<Integer> veryCoolSpy = new LinkedList<Integer>(); 22 23 @Test shouldPrintNiceName()24 public void shouldPrintNiceName() { 25 // when 26 veryCoolSpy.add(1); 27 28 try { 29 verify(veryCoolSpy).add(2); 30 fail(); 31 } catch (AssertionError e) { 32 Assertions.assertThat(e.getMessage()).contains("veryCoolSpy"); 33 } 34 } 35 } 36