State-Transition Diagrams

[article]
Testing UML Models, Part 4
  1. one initial state?
  2. If the state-transition diagram is an open-loop, is there at least one terminal state?
  3. If the state-transition diagram is a closed-loop, is it really? (Almost all are actually open-loop)
  4. Does each state have at least one exit transition?
  5. If multiple guards exist for a single event, are the guards mutually exclusive?
  6. Does each state have exactly one transition for each possible event-guard combination?
  7. Have all redundant or duplicate states or transitions been removed?
  8. Are all states reachable?
  9. Is every "real" state in the world represented by one and only one state on the diagram?
  10. Is each state and transition clearly named?
  11. Are all possible paths also valid paths?
  12. Are all valid paths represented?

Domain Expert Testing
After checking the syntax of the state-transition diagrams, we proceed to the second type of testing-domain expert testing. Again, we have two options: find a domain expert or attempt to become one. (The second approach is always more difficult than the first, and the first can be very hard.) Continuing, we ask three kinds of questions: Is it complete? Is it correct? Is it consistent?

Complete:

  1. Are all of the required states, events, guards, transitions, and actions shown on the diagram?
  2. Are all exceptional cases handled properly?

Correct:

  1. Are we using state-transition diagrams only for classes that have complex, interesting behavior?
  2. Does the diagram correctly represent the open-loop/closed-loop nature of the class?
  3. Are all of the required states, events, guards, transitions, and actions properly defined?

Consistent:

  1. Does a one-to-one correspondence exist between an object's events and its methods?

Traceability Testing

Finally, after having our domain expert scour the state-transition diagrams, we proceed to the third type of testing-traceability testing. We want to make certain that we can trace from the requirements to the state-transition diagrams and from the state-transition diagrams back to the requirements. Again, we turn to one question: Is it consistent?

Consistent:

  1. Do all states, events, guards, transitions, and actions in the requirements appear in the state-transition diagram?

Conclusion
This set of questions, based on syntax, domain expert, and traceability testing; and focused on completeness, correctness, and consistency; is designed to get you started testing in an area with which you may not be familiar.

This article concludes this series on object-oriented testing. In them we've introduced you to the four most important diagrams used in object-oriented development, described the UML notation used in these diagrams, and given you a set of practical questions you can ask to evaluate the quality of these object-oriented diagrams.

I hope they have been beneficial to you.

Other articles in this series:
Use Cases: Testing UML Models, Part 1

Sequence Diagrams: Testing UML Models, Part 2

Class Diagrams: Testing UML Models, Part 3

About the author

Lee Copeland's picture Lee Copeland

Lee Copeland has more than thirty years of experience in the field of software development and testing. He has worked as a programmer, development director, process improvement leader, and consultant. Based on his experience, Lee has developed and taught a number of training courses focusing on software testing and development issues. Lee is the managing technical editor for Better Software magazine, a regular columnist for StickyMinds.com, and the author of A Practitioner's Guide to Software Test Design. Contact Lee at lcopeland@sqe.com.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!

Upcoming Events

Nov 09
Nov 09
Apr 13
May 03