• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 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.Test;
8 import org.junit.runner.RunWith;
9 import org.mockito.Answers;
10 import org.mockito.Mock;
11 import org.mockito.junit.MockitoJUnitRunner;
12 
13 @RunWith(MockitoJUnitRunner.class)
14 public class DeepStubbingWithJUnitRunnerTest {
15 
16     private final SomeClass someClass = new SomeClass();
17 
18     @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Root root;
19 
20     @Test
deep_stubs_dont_trigger_unnecessary_stubbing_exception()21     public void deep_stubs_dont_trigger_unnecessary_stubbing_exception() {
22         //when
23         someClass.someMethod(root);
24 
25         //then unnecessary stubbing exception is not thrown
26     }
27 
28     public static class SomeClass {
someMethod(Root root)29         void someMethod(Root root) {
30             root.getFoo().getBar();
31         }
32     }
33 
34     interface Root {
getFoo()35         Foo getFoo();
36     }
37 
38     interface Foo {
getBar()39         Bar getBar();
40     }
41 
42     interface Bar {
43 
44     }
45 }
46