Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
4. (20) Testing
(a) (4) Explain why practitioners of eXtreme Programming believe that a test suite should be written before a class is implemented.
A test suite effectively defines a contract for services.
In more detail:
- Instances of a class provide services to other objects.
- The set of services can be thought of as a “contract” between the class and -its clients.
- A test suite serves as an operational way to define the contract.
Half-credit for an answer that describes why a test suite is useful but doesn't make the XP-related points above about why it should be written first.
(b) (8) Briefly describe one advantage and one disadvantage with regard to testing of the encapsulation provided by objects.
Advantage (4 points):
Because encapsulation enforces information hiding, undesirable dependencies between client and server classes are avoided. In particular, the implications of changes are restricted, thus simplifying testing after changes (regression testing).
In general, this answer should include something about encapsulation helping the user to avoid certain kinds of errors, thus making testing easier.
Disadvantage (4 points):
Encapsulation hides the states of an object, which must be manipulated in the testing process. Although encapsulation does not directly introduce faults, it may be an obstacle in testing by reducing controllability and observability.
In general, this answer should discuss how the testing process is made more difficult by the same attributes of encapsulation that make some kinds of errors less likely.
(c) (8) When implementing and testing a subclass of a parent class that is already considered “tested,” under what circumstances would it be necessary to retest some (or all) of the methods of the parent?
The general concept is that any situation where the existence of the subclass might make the parent class methods act differently must result in some additional testing of the parent class.
- Any parent class method that calls a method redefined by the subclass must be retested.
- Interactions betweem parent methods that access an instance variable and subclass methods that change the same variable must be tested.
Link to this Page