title: How to write a UT to mock an internal object in one method?
body: <p>For example , I have a java class as below. I am going to write a unit test for doWork(), so I would like to control obj's behavior. But it is obvious that obj is instantiated internally. </p>
  
  <p>How can I write this UT? Now I am using Junit+Mockito.</p>
  
  <pre><code>class ToBeTest{
      public ToBeTest(){}
      public boolean doWork(){
          OtherObject obj=new OtherObject();
          return obj.work();
      }
  }
  </code></pre>
  
  <p>Thanks in advance. :)</p>
  
  <p><strong>BTW, The reality is I am writing UT for other person's class. So I don't want to change it. It has been fully tested by integration test.</strong></p>