Excerpted from Testing Object-Oriented Systems: Models, Patterns, and Tools. Copyright (C) 2000, Robert V. Binder, all rights reserved.
A pattern is a general solution to a specific recurring design problem. It explains the insight and good practices that have evolved to solve the problem. It provides a concise definition of common elements, context, and essential requirements for a solution. Patterns were first used to describe constellations of structural elements in buildings and towns. For example, the "half-hidden garden" pattern considers how to frame a view of a garden so that onlookers have a sense of well-being and positive anticipation [Alexander 79].
Some designers of object-oriented systems began to express certain stereotypical relationships and class semantics following the style of architectural patterns [Coplien+95]. These software design patterns capture the essence of solutions to common software design problems. For example, the Model-View-Controller pattern suggests that three kinds of components should be used to provide an interactive display of stored values: classes that contain the stored information (the Model), classes for the user interface (the View), and classes that mediate interaction between the user interface and the content (the Controller) [Gamma+95]. Brad Appleton's Patterns in a Nutshell is an excellent introduction to design patterns.
The use of named generic solutions for software design predates the interpretation of design patterns for software. However, patterns are an improvement over ad hoc or idiosyncratic approaches. They encourage articulation and refinement of reusable solutions and offer a common point of view for their development and evaluation. The popularity of software design patterns mushroomed in the mid 1990s. Hundreds of patterns have been identified and published. In large part, this interest can be explained by the fact that patterns are pragmatic, simple, and reflect a professional consensus about good design.
A pattern template is a list of subjects (sections) that comprise a pattern. Several templates for software design patterns have been developed. The "Gang of Four" (GoF) template is used for patterns that describe constellations of classes that solve common software design problems of relatively small scope [Gamma+95]. The Siemens' template is similar and includes a section to discuss component structures of relatively large scope [Buschmann+96]. Patterns for test automation and built-in test presented in this book use the GoF design template. Firesmith used a variant of the GoF pattern, called a Pattern Language for Object-Oriented Testing (PLOOT) to describe both test drivers and test case design [Firesmith 96]. However, design of test cases and test suites must consider questions not relevant for software design.
The subjects, organization, and presentation of testing strategies in [Beizer 95] can be considered a pattern template for test design, suggesting the sections that a test design pattern should address. Each of the six chapters on generic testing strategies follows the same outline: (1) Relations and the Model, (2) Technique, (3) Application Indicators, (4) Bug Assumptions, (5) Limitations and Caveats, and (6) Automation and Tools.(1) Beizer's outline covers the essential questions that any test design approach must address. Each chapter is a pattern for test design. Siegel's "Test Models" for object-oriented development are similar in that the same subject outline is used for many testing problems: (1) Overview, (2) Leadership (general conditions and goals), (3) Structure (a model of the things to test ), (4) Dynamics (how to generate things that the model tests), (5) Example, and (6) Road Map (a graphic summary of the model) [Siegel 96]. Siegel's test models are less elaborate than Beizer's outline, but can also be considered as a kind of test design pattern.
The test design pattern template incorporates these test-specific elements and sections considered essential for any pattern template. The sections of the test design template follow. They are questions to the pattern writer, whose answers should articulate the insights, assumptions, and mechanics of the test strategy presented in the pattern.
Test design patterns are compatible with most test processes. There are no essential differences in the basic tasks of testing when one uses a test pattern. Test patterns simply frame and focus the issues that must be resolved to accomplish any kind of testing. Patterns support results-oriented testing: that is, a scope-appropriate responsibility model of the implementation under test is needed. It is assumed that the IUT runs well enough to allow testing to proceed. The basic steps for using a test pattern are as follows.
1. The six design chapters are Control-Flow Testing, Loop Testing, Data-Flow Testing, Transaction-Flow Testing, Domain Testing, Syntax Testing, and Finite-State Testing.
2. These conditions are called the "ideal fault conditions" in [Marick 95] and the "fault/failure model" in [Friedman+95].
3. Test-ready was coined by Bob Poston. As an adjective, it means that test design or test execution may proceed without interference caused by missing or incomplete specifications and/or implementations. A test readiness assessment is a formal process activity defined in the SEI Capability Maturing Model which determines the test-readiness of a work-product [SEI 93].
4. Studies indicate that testing effectiveness reaches a plateau related to test scope [Horgan 96].
[Alexander 79] Christopher Alexander. The timeless way of building. New York: Oxford University Press, 1979.
[Beizer 95] Boris Beizer. Black box testing. New York: John Wiley & Sons, 1995.
[Buschmann+96] Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. Pattern-Oriented Software Architecture: A System of Patterns. New York: John Wiley & Sons, 1996.
[Coplien+95] James Coplien and Douglas Schmidt (eds.) Pattern languages of program design. Reading, Mass.: Addison-Wesley, 1995.
[Firesmith 96] Donald G. Firesmith. Pattern language for testing object-oriented software. Object Magazine 5(9):32-28, January 1996.
[Friedman+95] Michael A. Friedman and Jeffery M. Voas. Software assessment: reliability, safety, testability. New York: John Wiley & Sons, Inc, 1995.
[Gamma+ 95] Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design patterns: elements of reusable object-oriented software. Reading Mass.: Addison-Wesley, 1995.
[Horgan+96] Joseph R. Horgan and Aditya P. Mathur. Software testing and reliability. In Michael R. Lyu (ed). Handbook of software reliability engineering. Los Alamitos, Calif.: IEEE Computer Society Press, 1996.
[Marick 95] Brian Marick. The Craft of software testing. Englewood Cliffs, New Jersey: Prentice-Hall, Inc., 1995.
[SEI 93] Mark C. Paulk, Bill Curtis, Mary Beth Chrissis, and Charles V. Weber. Capability Maturity Model for Software, Version 1.1. CMU/SEI-93-TR-24. Pittsburgh: Software Engineering Institute, 1993.
[Siegel 96] Shel Siegel. Object-oriented software testing: a hierarchical approach. New York: John Wiley and Sons, 1996.