5-1. Identify test requirements for the constructors and reverse() operators for the Velocity class (see Figure 5.3). Consider the difference in requirements between the contract and defensive programming approaches. Construct the test cases for the requirements you identify. 5-2. Do the same for an elementary class that you have. 5-3. Write a test driver to implement the test cases you constructed in either of the previous exercises. If you are implementing in C++ or Java, you can start with the Tester abstract classes described at the end of this chapter. 5-4. Write a specification for an abstract Tester class that would be useful in your organization. 5-5. Consider the dilemma of baseline testing. In a specification-based approach, the Tester class must make judgments based solely on the apparent consistency of all attributes of an object when it is in some given state. On the other hand, an implementation-based approach strongly couples the code between a Tester and its CUT so that a Tester's implementation cannot be completed until the CUT's code is mostly completed. Under what circumstances would you support testing based solely on specification? Under what circumstances would you insist on using both approaches? |