How Can I Use the Analysis and Design Models?

The use of UML analysis and design models as part of testing is straightforward. You use these diagrams to design the low-level components of your system. Therefore, these diagrams can directly aid in unit testing—that is, the testing of the individual system components prior to integration with others, typically performed by the developer who has created the component.

Consider the use case diagram in Figure 7-10. This is a use case diagram of a subsystem, which is part of a medical records system that is responsible for compliance with state regulations. [NAIB3] (Note: An MDS [Minimum Data Set] is a specific extraction of certain information from the clinical records of a patient.)

Figure 7-10. Use case diagram of compliance subsystem.


Unit, Class, and Algorithmic Testing

Use cases are a representation of your requirements. Thus, each of these use cases can provide the details for individual unit test plans As you develop these use cases, you create use case specifications (textual), sequence diagrams, class diagrams, and possibly other UML diagrams. The use case specifications and sequence diagrams (see Figure 7-11) can fill in the details of the unit test procedure for these use cases, similar to what we discussed earlier in this chapter for higher-level testing.

Figure 7-11. Transmit MDS sequence diagram. [NAIB4]


These design diagrams, used in conjunction with the related class diagrams (see Figure 7-12), can form the basis for the detailed structural (i.e., white box) testing of this specific component and its classes.

Figure 7-12. Transmit MDS class diagram. [NAIB5]


If you are testing classes individually, additional UML diagrams can help. For example, an activity diagram can help design and document a complex mathematical algorithm performed by a class. Such a diagram would map out the flow and steps of the algorithm. If a class has particularly complex behavior or is event-driven, you can depict the manner in which this class operates with a statechart diagram, which depicts the state of an object, the actions it performs, and the events that trigger it to change its state. Figure 7-13 shows a statechart for a transaction, specifically the processing of an order to buy a security.

Figure 7-13. Statechart for a securities transaction.


You can use the statechart to direct how to drive the testing of the class (actually, an object) by creating the various events shown on the transitions (i.e., the arrows). This enables you to verify that the class is processing correctly. Indeed, some modern modeling tools you to automate the creation of statechart diagrams for testing purposes.) You will learn more about statecharts (called state machine diagrams in UML 2.0) in Chapter 8, “Is That All There Is?.”

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset