• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.assertj.core.api.Assertions;
9 import org.junit.Test;
10 import org.mockito.Spy;
11 import org.mockitoutil.TestBase;
12 
13 import java.util.LinkedList;
14 import java.util.List;
15 
16 import static org.junit.Assert.fail;
17 import static org.mockito.Mockito.verify;
18 
19 //see issue 216
20 public class SpyShouldHaveNiceNameTest extends TestBase {
21 
22     @Spy List<Integer> veryCoolSpy = new LinkedList<Integer>();
23 
24     @Test
shouldPrintNiceName()25     public void shouldPrintNiceName() {
26         //when
27         veryCoolSpy.add(1);
28 
29         try {
30             verify(veryCoolSpy).add(2);
31             fail();
32         } catch(AssertionError e) {
33             Assertions.assertThat(e.getMessage()).contains("veryCoolSpy");
34         }
35     }
36 }
37