• 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 package org.mockitousage.junitrunner;
6 
7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.fail;
9 import static org.mockito.Mockito.verify;
10 import static org.mockito.Mockito.when;
11 
12 import org.junit.Before;
13 import org.junit.Ignore;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.Mock;
17 import org.mockito.junit.MockitoJUnitRunner;
18 import org.mockitousage.IMethods;
19 import org.mockitoutil.TestBase;
20 
21 // @RunWith(ConsoleSpammingMockitoJUnitRunner.class)
22 @RunWith(MockitoJUnitRunner.class)
23 @Ignore
24 public class ModellingVerboseMockitoTest extends TestBase {
25 
26     @Mock private IMethods mock;
27 
28     @Before
cleanStackTraces()29     public void cleanStackTraces() {
30         super.makeStackTracesClean();
31     }
32 
33     @Test
shouldLogUnusedStubbingWarningWhenTestFails()34     public void shouldLogUnusedStubbingWarningWhenTestFails() throws Exception {
35         when(mock.simpleMethod(1)).thenReturn("foo");
36         when(mock.otherMethod()).thenReturn("foo");
37         when(mock.booleanObjectReturningMethod()).thenReturn(false);
38 
39         // TODO: stubbed with those args here -> stubbed with certain args here
40         String ret = mock.simpleMethod(2);
41 
42         assertEquals("foo", ret);
43         // TODO: should show message from actual failure not at the bottom but at least below 'the
44         // actual failure is ...'
45     }
46 
47     @Test
shouldNotLogAnythingWhenNoWarnings()48     public void shouldNotLogAnythingWhenNoWarnings() throws Exception {
49         // stub
50         when(mock.simpleMethod()).thenReturn("foo");
51         // use stub:
52         mock.simpleMethod();
53         // verify:
54         verify(mock).simpleMethod();
55         // should be no warnings:
56         fail();
57     }
58 }
59