• 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 org.junit.Before;
8 import org.junit.Ignore;
9 import org.junit.Test;
10 import org.junit.runner.RunWith;
11 import org.mockito.Mock;
12 import org.mockito.junit.MockitoJUnitRunner;
13 import org.mockitousage.IMethods;
14 import org.mockitoutil.TestBase;
15 
16 import static junit.framework.TestCase.assertEquals;
17 import static junit.framework.TestCase.fail;
18 import static org.mockito.Mockito.verify;
19 import static org.mockito.Mockito.when;
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 actual failure is ...'
44     }
45 
46     @Test
shouldNotLogAnythingWhenNoWarnings()47     public void shouldNotLogAnythingWhenNoWarnings() throws Exception {
48         //stub
49         when(mock.simpleMethod()).thenReturn("foo");
50         //use stub:
51         mock.simpleMethod();
52         //verify:
53         verify(mock).simpleMethod();
54         //should be no warnings:
55         fail();
56     }
57 }
58