How would you design a focused test strategy for object composition with inputs from an untrusted API?
Answer
Build the smallest useful model of the behavior by making inputs, outputs, ownership and failure behavior explicit before choosing an implementation. Focus on object composition with inputs from an untrusted API. Use small deterministic units plus integration behavior at real boundaries as the oracle. Cover normal flow, invalid inputs, exceptions, concurrency and resource cleanup. Keep data and dependencies controlled enough to reproduce failures. Release only when tests fail for one understandable reason and the code remains easy to change.
Strong answer includes
- explicit risk and test oracle for object composition
- controls side effects and dependencies
- designs for deterministic tests
- measurable evidence and residual-risk statement
Practical example
A ShippingAddress object was composed directly from a third-party geocoding API's response, and a malformed response once left the object with a null country field that broke downstream tax calculation. The strategy separated a strict validating parser from the composition step itself, with unit tests for the parser against malformed payloads and a smaller set of integration tests for the composed object against a contract-tested mock.