I have similar questions on this board, but none of them answer my question. It sounds strange, but is it possible to scoff at calling a constructor on an object that you are mocking.
Example:
class RealGuy { .... public void someMethod(Customer customer) { Customer customer = new Customer(145); } } class MyUnitTest() { public Customer customerMock = createMock(Customer.class) public void test1() {
How can I expect a constructor call? I can change the call to the Customer constructor to use newInstance, but I'm not sure if this will help. I cannot control what the body of the new Customer(145) constructor does.
Is it possible?
Setzer
source share