I see two situations where you should use a larger test:
- You have exercised each class individually, but the overall behavior is composed of many classes, and you want to see them work together. Think of a set of classes that calculates the final cost of a shopping cart. You have unit-tested the class responsible for business rule 1 and the class responsible for business rule 2. But you still want to see the final cost of the shopping cart after all the rules have been applied to it.
- The class you want to test is a component in a larger plug-and-play architecture. One of the main advantages of object-oriented design is that we can encapsulate and abstract repetitive complexity, so the user only has to implement what matters. Think of a plugin for your favorite IDE (in my case, IntelliJ). You can develop the logic of the plugin, but many actions will only happen when IntelliJ calls the plugin and passes parameters to it.
The following sections show examples of both cases and will help you generalize them.
Leave a Reply