title: How do I verify a method call that is in a constructor?
body: <p>I have a constructor which makes a call to two methods. They are both void, and I just want to verify that they are called.</p>
  
  <p><strong>Foo.java</strong></p>
  
  <pre><code>public class Foo {
  
      public Foo(String name, Object obj) {
           init(name);
           doSomething(obj);
      }
  }
  </code></pre>
  
  <p><strong>FooTest.java</strong></p>
  
  <pre><code>@Test
  public void constructor_test throws Exception {
      Foo foo = Mockito.mock(Foo.class);
      PowerMockito.whenNew(Foo.class).withAnyArguments().thenReturn(foo);
      Foo f = new Foo("name");
      verify(f).init(Mockito.anyString()); 
      verify(f).doSomething(Mockito.any(Object.class)); 
  }
  </code></pre>
  
  <p>The unit test fails with a message saying that there were zero interactions with the mock <strong>foo.init();</strong>.</p>
  
  <p>How do a verify a method call that is within a constructor?</p>