OOPortal OOPortal


Object Diagrams  «Prev  Next»
Lesson 4A simple test
ObjectiveApply Object Diagrams to test Class Diagrams

Apply Object Diagrams to test Class Diagrams

A valuable testing method

It is very easy to draw a class diagram and assume that it is correct. A teammate of mine brought me this class diagram for an application that manages triangles and the points that define them, sure that it is too simple to be wrong. If errors can be made on such a simple model, think of how valuable a testing method would be for very complex models.

Triangle class diagram is defined by Point
Now let's use the object diagram to verify the Triangle class diagram. We will step through the construction of an object diagram that models a set of test cases. The construction will demonstrate the model elements of the diagram as well as illustrate how the object diagram maps to test cases.

Test data

Points
Point ID X Coordinate Y Coordinate
A 1 1
B 1 2
C 2 1
D 2 2
E 3 2
F 1 2
G 1 2

Triangles
Triangle ID
1
2
3
4

Test cases

  1. Define Triangle 1 with Points A, B, and C.
  2. Add Triangle 2 to the same diagram with Points B, C, and D.
  3. Add Triangle 3 to the same diagram with Points B, D, and E.
  4. Add Triangle 4 to the same diagram with Points B, F, and G.

  1. Draw an object diagram to represent Triangle 1 with Points A,B, and C.
  2. Draw an object to represent Point A, name the object, and document the attribute values.
  3. Add Points B and C, name them and add the attribute values. Draw links between Triangle 1 and Points A,B, and C and label them.
  4. Add Triangle 2 to the diagram along with its defining points. Add Triangle2, name it and add its attribute value.
  5. Add Point D, name it and add the attribute values. Next draw a link between Triangle 2 and Point D and label it.
  6. Add Triangle 3 to the diagram along with its defining Points. Add Triangle 3, name it and add the attribute values.
  7. Add Point E, name it and add the attribute values. Next draw a link between Triangle 3 and Point E and label it.
  8. Add Triangle 4 to the diagram with its defining points. Add Triangle 4, name it and add the attribute values.
  9. Add points F and G, name them and add the attribute values. Finally draw links between Triangle 4 and Points F and G and label them.


A full page transcript of the slide show above can be found at the following link.
Triangle Object Diagram
As you can see, using the object diagram to test the class diagram reveals that my teammate made some errors.
The next lesson concludes this module.

Testing Diagrams - Exercise

Click the Exercise link below to identify the changes that need to be made to correct the original class diagram.
Testing Diagrams - Exercise