title: How to mock another method in the same class which is being tested?
body: <p>I am writing JUnit Test case for a class which has two methods methodA,methodB.
  I would like to mock the call to the methodB from methodA in my test case 
  I am using spy on the class which I am testing, but still the methodB gets executed.</p>
  
  <p>here is the class</p>
  
  <pre><code> public class SomeClass
  {
  
       public Object methodA(Object object) 
      {
           object=methodB(object);
  
          return object;
      }
  
  
  
      public Object methodB(Object object) 
      {
          //do somthing
          return object;
      }
  }
  </code></pre>
  
  <p>here is the test class</p>
  
  <pre><code>  @RunWith( org.powermock.modules.junit4.legacy.PowerMockRunner.class )
      @PrepareForTest(SomeClass.class)
      public class SomeClassTest { 
  
          private SomeClass var = null; 
  
  
          @Before
          public void setUp() {
  
              var=new SomeClass();
  
          }
  
          @After
          public void tearDown()
              {
              var= null;
  
          }
  
          @Test
          public void testMethodA_1()
              throws Exception {
              Object object =new Object();
          SomeClass spy_var=PowerMockito.spy(var);
          PowerMockito.when(spy_var.methodB(object)).thenReturn(object);
  
      Object result = var.methodA(object);        
  
          assertNotNull(result);
  
          }
  
      }
  </code></pre>
  
  <p>The method B still gets the called though I have mocked it 
  PLease suggest me a solution with the proper way of mocking the methodB call from methodA of the same class.</p>