title: Use mock object in test method implementation
body: <p>I have a question. There's a method with implementation using another objects. I'd like to test this method which will not using another objects invoking.</p>
  
  <pre><code>class Object1 {
  
      public void method1() {
          Object2 object2 = new Object2();
          String info = object2.getInfo();
          // ...
          // working with info, which I want to test
          // ...
      }
  
  }
  
  class Object1Test {
      @Test
      public void testMethod1() {
          Object1 object1 = new Object1();
          object1.method(); // want to run this method without invoking Object2
      }
  }
  </code></pre>
  
  <p>Could you help me to understand how in junit while testing method1() can I mock the using of Object2 with something like Object2Mock?</p>