0809 Cover 5/29/02 1:47 PM Page 1 C M Y CM MY CY CMY K SOFTWAR E TESTING A Craftsman's Approach SECOND EDITION 0809_frame_FM.fm Page ii Tuesday, February 18, 2014 3:08 PM SOFTWAR E TESTING A Craftsman's Approach SECOND EDITION Paul C. Jorgensen, Ph.D. Department of Computer Science and Information Systems Grand Valley State University Allendale, Michigan and Software Paradigms Rockford, Michigan CRC PR ESS Boca Raton London New York Washington, D.C. CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2003 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Version Date: 20140210 International Standard Book Number-13: 978-1-4822-5332-0 (eBook - PDF) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the valid- ity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or uti- lized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopy- ing, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http:// www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com 0809_frame_FM.fm Page v Tuesday, February 18, 2014 3:08 PM Dedication To Carol, Kirsten, and Katia v 0809_frame_FM.fm Page vi Tuesday, February 18, 2014 3:08 PM 0809_frame_FM.fm Page vii Tuesday, February 18, 2014 3:08 PM Preface to the First Edition We huddled around the door to the conference room, each taking a turn looking through the small window. Inside, a recently hired software designer had spread out source listings on the conference table, and carefully passed a crystal hanging from a long chain over the source code. Every so often, the designer marked a circle in red on the listing. Later, one of my colleagues asked the designer what he had been doing in the conference room. The nonchalant reply: “Finding the bugs in my program.” This is a true story, it happened in the mid-1980s when people had high hopes for hidden powers in crystals. In a sense, the goal of this book is to provide you with a better set of crystals. As the title suggests, I believe that software (and system) testing is a craft, and I think I have some mastery of that craft. Out of a score of years developing telephone switching systems, I spent about a third of that time on testing: defining testing methodologies and standards, coordinating system testing for a major international telephone toll switch, specifying and helping build two test execution tools (now we would call them CASE tools), and a fair amount of plain, hands-on testing. For the past seven years, I have been teaching software engineering at the university graduate level. My academic research centers on specification and testing. Adherents to the Oxford Method claim that you never really learn something until you have to teach it — I think they’re right. The students in my graduate course on testing are all full-time employees in local industries. Believe me, they keep you honest. This book is an outgrowth of my lectures and projects in that class. I think of myself as a software engineer, but when I compare the level of precision and depth of knowledge prevalent in my field to those of more traditional engineering disciplines, I am uncomfortable with the term. A colleague and I were returning to our project in Italy when Myers’ book, The Art of Software Testing, first came out. On the way to the airport, we stopped by the MIT bookstore and bought one of the early copies. In the intervening 15 years, I believe we have moved from an art to a craft. I had originally planned to title this book “The Craft of Software Testing,” but as I neared the final chapters, another book with that title appeared. Maybe that’s confirmation that software testing is becoming a craft. There’s still a way to go before it is a science. Part of any craft is knowing the capabilities and limitations of both the tools and the medium. A good woodworker has a variety of tools and, depending on the item being made and the wood being used, knows which tool is the most appropriate. Of all the phases of the traditional Waterfall Model of the software development life cycle, testing is the most vii 0809_frame_FM.fm Page viii Tuesday, February 18, 2014 3:08 PM viii Software Testing: A Craftsman’s Approach, Second Edition amenable to precise analysis. Elevating software testing to a craft requires that the testing craftsperson know the basic tools. To this end, Chapters 3 and 4 provide mathematical background that is used freely in the remainder of the text. Mathematics is a descriptive device that helps us better understand software to be tested. Precise notation, by itself, is not enough. We must also have good technique and judgment to identify appropriate testing methods and to apply them well. These are the goals of Parts II and III, which deal with fundamental functional and structural testing techniques. These techniques are applied to the continuing examples, which are described in Chapter 2. In Part IV, we apply these techniques to the integration and system levels of testing, and to object-oriented testing. At these levels, we are more concerned with what to test than how to test it, so the discussion moves toward requirements specification. Part IV concludes with an examination of testing interactions in a software controlled system, with a short discussion of client–server systems. It is ironic that a book on testing contains faults. Despite the conscientious efforts of reviewers and editors, I am confident that faults persist in the text. Those that remain are my responsibility. In 1977, I attended a testing seminar given by Edward Miller, who has since become one of the luminaries in software testing circles. In that seminar, Miller went to great lengths to convince us that testing need not be bothersome drudgery, but can be a very creative, interesting part of software development. My goal for you, the reader of this book, is that you will become a testing craftsperson, and that you will be able to derive the sense of pride and pleasure that a true craftsperson realizes from a job well done. Paul C. Jorgensen Rockford, Michigan January 1995 0809_frame_FM.fm Page ix Tuesday, February 18, 2014 3:08 PM Preface Seven years have passed since I wrote the preface to the first edition. Much has happened in that time, hence this new edition. The most significant change is the dominance of the unified modeling language (UML) as a standard for the specification and design of object- oriented software. The main changes in this edition are the five chapters in Part V that deal with testing object-oriented software. Nearly all the material in Part V is UML-based. The second major change is that the Pascal examples of the first edition are replaced by a language-neutral pseudocode. Most of the examples have been elaborated, and they are supported by Visual Basic executable modules available on the CRC Press Web site (www.crcpress.com). Several new examples illustrate some of the issues of testing object- oriented software. Dozens of other changes have been made; the most important additions include an improved description of equivalence class testing, a continuing case study, and more details about integration testing. I am flattered that the first edition is one of the primary references on software testing in the trial–use standard Software Engineering Body of Knowledge jointly produced by the ACM and IEEE Computer Society (www.swebok.org). This recognition makes the problem of uncorrected mistakes more of a burden. A reader in South Korea sent me a list of 38 errors in the first edition, and students in my graduate class on software testing have gleefully contributed others. There is a nice analogy with testing here: I have fixed all the known errors, and my editor tells me it is time to stop looking for others. If you find any, please let me know — they are my responsibility. My e-mail address is: [email protected]. I need to thank Jerry Papke and Helena Redshaw at CRC Press for their patience. I also want to thank my friend and colleague, Prof. Roger Ferguson, for his continued help with the new material in Part V, especially the continuing object-oriented calendar example. In a sense, Roger has been a tester of numerous drafts of Chapters 16 through 20. Paul C. Jorgensen Rockford, Michigan May 2002 ix