title: how to mock method from calling class using mockito in java
body: <p>I have a class that calls method from another class to get the report status.</p>
  
  <pre><code>Class A {
    private classb b = new classb();
    method x() {
      String xyz =b.method1( parm1, parm2) 
    }
  }
  </code></pre>
  
  <p>So, when for Junit test for method x getting null pointer on b.method(). I have created mock for class b and did following</p>
  
  <pre><code>Mockito.doReturn(val).when(classbMock).method1(parm1,parm2);
  </code></pre>
  
  <p>Please help how can I mock the class b and get pass it.</p>
  
  <p>Thanks</p>