Does anybody know of a way in powermock you can unit test a constructor and mock the methods that the constructor calls.
i.e. I have a class like this;
public class myClass {
public myClass(){
myMethod();
// do other stuff
}
public void myMethod(){
// do stuff
}
}
What I want to do is write a unit test for myClass()
constructor that mocks myMethod()
.
This would be easy if myMethod()
was static as I could use mockStaticPartial()
then invoke the constructor.
Just creating a partial mock of MyClass won't work either as once I've created the mock I've created it, invoking the constructor at that point will just create a new instance of MyClass without myMethod()
being mocked.
Anyone know of any ways?