Suppose we have a hierarchy like the following, where each thing under it means it is composed of that type:
CarCompany | CarFactory | Car | Engine | +------+-----+ | | | PartA PartB PartC
For everything above, also assume each component has logic associated with it and it's not just a glorified collection. As such, a
CarCompany owns many
CaryFactorys, which in turn makes multiple
Cars, which have their own possible
Engine types, and those are made up of atomic
Now suppose that we have interfaces used for each step, like:
CarCompanyadds new factories with a
CarFactoryadds cars by a
Caradds its engine by an
As such, this makes unit testing easier since we can mock the interfaces and make sure the logic works without spending forever instantiating stuff.
When it comes to integration testing however, we want to make sure everything works as intended... but at what level do we do integration testing? Do we do a bunch of integration tests at the top level? Or do we do one for each level that accepts an interface?
Reason I'm asking is because integration testing is suppose to make sure our classes integrate together by definition, which means wherever we have an interface we want to test with concrete instances. However this implies that we would do testing at
N - 1 levels for
N levels, since the bottom level does not need to be tested. Is this overkill though? Or should integration testing only be done at the top level?