2 be more explicit that changing the object creation is wrong
source | link

I would treat it as single unit to test.

As long as you control all inputs from which the Employee object is created, the fact that it is created in the tested object shouldn't matter. You just need a the mock method to return expected result if the content of the argument matches expectation.

Obviously it means you need to provide custom logic for the mock method. Advanced logic often can't be tested with just "for x return y" kind of mocks.

In fact, you should not make it return different object in the tests than it will in production, because if you did, you wouldn't be testing the code that should create it. But that code is integral part of the production code and therefore should be covered by the test case too.

I would treat it as single unit to test.

As long as you control all inputs from which the Employee object is created, the fact that it is created in the tested object shouldn't matter. You just need a the mock method to return expected result if the content of the argument matches expectation.

Obviously it means you need to provide custom logic for the mock method. Advanced logic often can't be tested with just "for x return y" kind of mocks.

I would treat it as single unit to test.

As long as you control all inputs from which the Employee object is created, the fact that it is created in the tested object shouldn't matter. You just need a the mock method to return expected result if the content of the argument matches expectation.

Obviously it means you need to provide custom logic for the mock method. Advanced logic often can't be tested with just "for x return y" kind of mocks.

In fact, you should not make it return different object in the tests than it will in production, because if you did, you wouldn't be testing the code that should create it. But that code is integral part of the production code and therefore should be covered by the test case too.

1
source | link

I would treat it as single unit to test.

As long as you control all inputs from which the Employee object is created, the fact that it is created in the tested object shouldn't matter. You just need a the mock method to return expected result if the content of the argument matches expectation.

Obviously it means you need to provide custom logic for the mock method. Advanced logic often can't be tested with just "for x return y" kind of mocks.