title: Mockito- mock field in class
body: <p>I have got a question connected with Mockito framework. Is there any way to mock a field inside a class? Lets say we have got:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Component
  public class A{
      @Autowired
      B b;
  
      public methodExample(){b.doSth();}
  }
  
  
  class C {
      @Autowired
      A a;
  }
  
  @Test
      public void testMethodExample(){...}
  }
  </code></pre>
  
  <p>Is there any possibility to mock B object in order to impose return value of method doSth? I know I can pass mocked object as an argument of constructor but I wonder if there is any other option?</p>