A big part of unit testing is mocking object that a class depends on so that you are testing solely that class. However, there are cases where you want to ensure that an entire composition of objects is working together: usually, this is as simple as making unit tests that cover higher level interfaces... sans the mocks.Quotes are examples
What I've discovered recently, however, is that when adding extra behaviors to a method using composition, the integration test ends up getting separated from the rest of the tests for that method.The class Clock depends on an internal time object. When testing the clock, the time object should be mocked, so that you're only testing clock. However, it's a good idea to also test the clock and the time object at the same time.
Does the test for Order -> SushiMachine ->Sushi belong in the SushiMachine object, or the specific SushiWidget it's testing?We have a SushiMachine, which takes string orders and converts them into Sushi object. The machine is composed of SushiWidgets, which each are responsible for creating a certain type of sushi. A SushiWidget can be tested individually to determine whether or not it creates the right Sushi based on the parameters that the SushiMachine extracted out of the Order, but you also want to test the SushiMachine to make sure it gives back the right Sushi from an order, i.e.
Order -> SushiMachine -> ParsedOrderForm
ParsedOrderForm -> SushiWidget -> Sushi
Order -> SushiMachine -> Sushi !
I hope I was comprehensible.