I have code that follows this pattern.
Class Factory build: returns: Add|Remove|Stub takes: property1, property2, property3 Class Add execute: does something takes: property2, propery3 Class Remove execute: does something takes: property2 Class Null execute: does nothing takes: nothing
In addition to verifying that the Factory:build produces the correct object I want to test that the 'property' values are passed through correctly.
It seems like the best place to do this is in the factory unit test but the assert would look like this.
this->assertEquals( property1, returnedObject->get... );
This smells bad to me because the test is actually testing the returnedObject and not the Factory itself. However, since the factory is generating those objects, it feels correct to test that they are generated properly.
By calling assert on the returned object, the unit test is testing the behavior of that object and not Factory. Failures in that object could cause the Factory unit-test to fail even though the Factory is passing the correct data into it's output.
Thus changes to the Add/Remove/Null objects could cause the Factory to fail before the executable objects are even tested.
What's the correct approach?