title: Mockito.verify and Mockito.doNothing are not working in Junit Test cases
body: <p>I have posted sample code which matches to my requirement in writing test case for create method using Mockito.verify() or doNothing(). I wanted to verify or doNothing () returns when create() method of ClassB without hitting DB.I have tried myself indifferent ways not worked for me and which are commented with outputs in Test Class.Any help would be appreciated</p>
  
  <pre><code> public class ClassA {
          ClassB b=new ClassB();
  
          public TestPojo create(TestPojo t) {        
              TestPojo t2= b.create(t);       
              return t2;          
          }    
      }
  
      public class ClassB {
  
      public TestPojo create(TestPojo t) {
          System.out.println("class b");
              return t;       
          }
  
      }
  
  public class TestPojo {
  
      private Integer id;
      private String name;
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  }
  
  import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  import org.mockito.Mockito;
  
      public class ClassTest {
  
  
              @Test
              public void testCreate_1()
                  throws Exception {
                  ClassA testA=Mockito.spy(new ClassA());
                  ClassB testB=Mockito.spy(new ClassB());         
                  TestPojo test=Mockito.spy(new TestPojo());
                  test.setId(1);
                  //Mockito.verifyZeroInteractions(testB); -- testcase is passed but executing ClassB method but this not our intension
                  //Mockito.verify(testB).create(test); --error output : Wanted but not invoked
                  //Mockito.doNothing().when(testB).create(test); --error output : Only void methods can doNothing()!
                  TestPojo act=testA.create(test);
                  //System.out.println(act.getId());
  
              }
          @Before
          public void setUp()
              throws Exception {
          }   
          @After
          public void tearDown()
              throws Exception {
              // Add additional tear down code here
          }
          public static void main(String[] args) {
              new org.junit.runner.JUnitCore().run(ClassTest.class);
          }
  
      }
  </code></pre>