title: Make stab for method throwing an exception in Mockito partial mock
body: <p>I'm new to Mockito and I need to use a partial mock of a class <code>ClassToTest1</code> and call real method <code>somethingToTestVoid</code>. But the problem is this method calls another method <code>doSomething</code>, that throws an exception and I need just to make a stub for it.</p>
  
  <pre><code>public class ClassToTest1 {
  
      private ClassToTest2 c2;
  
      public ClassToTest2 getC2() {
          return c2;
      }
  
      public void setC2(ClassToTest2 c2) {
          this.c2 = c2;
      }
  
      public void somethingToTestVoid() throws Exception {
          c2 = new ClassToTest2();
          c2.doSomething();
          System.out.println("OK!");
      }
  }
  
  
  public class ClassToTest2 {
  
      public ClassToTest2() {
      }
  
      public void doSomething() throws Exception {
          throw new Exception("");
      }
  }
  </code></pre>
  
  <p>And in a test class I'm trying to do something like this:</p>
  
  <pre><code>@Test
      public void test1() throws Exception {
            ClassToTest1 c1 = Mockito.mock(ClassToTest1.class);
            Mockito.doCallRealMethod().when(c1).somethingToTestVoid();
            Mockito.doCallRealMethod().when(c1).setC2(Mockito.any());
            ClassToTest2 c2 = Mockito.mock(ClassToTest2.class);
            c1.setC2(c2);
  
            Mockito.doNothing().when(c2).doSomething();
            c1.somethingToTestVoid();
      }
  </code></pre>
  
  <p>But still Exception is thrown in <code>doSomething</code>, because mocked <code>c2</code> and c2 which is used in <code>somethingToTestVoid</code> are different objects.</p>