title: Mock class in class under test
body: <p>How I can mock with Mockito other classes in my class which is under test?</p>
  
  <p>For example:</p>
  
  <p>MyClass.java</p>
  
  <pre><code>class MyClass {
      public boolean performAnything() {
          AnythingPerformerClass clazz = new AnythingPerformerClass();
          return clazz.doSomething();        
      }
  }
  </code></pre>
  
  <p>AnythingPerformerClass.java</p>
  
  <pre><code>class AnythingPerformerClass {
      public boolean doSomething() {
          //very very complex logic
          return result;
      }
  }
  </code></pre>
  
  <p>And test:</p>
  
  <pre><code>@Test
  public void testPerformAnything() throws Exception {
      MyClass clazz = new MyClass();
      Assert.assertTrue(clazz.performAnything());
  }
  </code></pre>
  
  <p>Can I spoof <code>AnythingPerformerClass</code> for excluding unnecessary logic from <code>AnythingPerformerClass</code>? Can I override <code>doSomething()</code> method for simple return <code>true</code> or <code>false</code>?</p>
  
  <p>Why I specify Mockito, because I need it for Android testing with Robolectric.  </p>