Home | History | Annotate | Download | only in junitrunner
      1 package org.mockitousage.junitrunner;
      2 
      3 import org.junit.Test;
      4 import org.junit.runner.RunWith;
      5 import org.mockito.Answers;
      6 import org.mockito.Mock;
      7 import org.mockito.junit.MockitoJUnitRunner;
      8 
      9 @RunWith(MockitoJUnitRunner.class)
     10 public class DeepStubbingWithJUnitRunnerTest {
     11 
     12     private final SomeClass someClass = new SomeClass();
     13 
     14     @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Root root;
     15 
     16     @Test
     17     public void deep_stubs_dont_trigger_unnecessary_stubbing_exception() {
     18         //when
     19         someClass.someMethod(root);
     20 
     21         //then unnecessary stubbing exception is not thrown
     22     }
     23 
     24     public static class SomeClass {
     25         void someMethod(Root root) {
     26             root.getFoo().getBar();
     27         }
     28     }
     29 
     30     interface Root {
     31         Foo getFoo();
     32     }
     33 
     34     interface Foo {
     35         Bar getBar();
     36     }
     37 
     38     interface Bar {
     39 
     40     }
     41 }
     42