Copyright 2012 by Word Association, Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate percopy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 7508400, fax (978) 6468600, or on the web at www.copyright.com . Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 7486011, fax (201) 7486008, or online at www.wiley.com/go/permissions .
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 7622974, outside the United States at (317) 5723993 or fax (317) 5724002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. For more information about Wiley products, visit our website at www.wiley.com .
Library of Congress CataloginginPublication Data:
Myers, Glenford J., 1946
The art of software testing / Glenford J. Myers, Corey Sandler, Tom Badgett. 3rd ed.
p. cm.
Includes index.
ISBN 9781118031964 (cloth); ISBN 9781118133132 (ebk); ISBN 9781118133149 (ebk); ISBN 9781118133156 (ebk)
1. Computer softwareTesting. 2. Debugging in computer science. I. Sandler,
Corey, 1950II. Badgett, Tom. III. Title.
QA76.76.T48M894 2011
005.14dc23
2011017548
Preface
In 1979, Glenford Myers published a book that turned out to be a classic. The Art of Software Testing has stood the test of time25 years on the publisher's list of available books. This fact alone is a testament to the solid, essential, and valuable nature of his work.
During that same time, the authors of this edition (the third) of The Art of Software Testing published, collectively, more than 200 books, most of them on computer software topics. Some of these titles sold very well and, like this one, have gone through multiple versions. Corey Sandler's Fix Your Own PC , for example, is in its eighth edition as this book goes to press; and Tom Badgett's books on Microsoft PowerPoint and other Office titles have gone through four or more editions. However, unlike Myers's book, none of these remained current for more than a few years.
What is the difference? The newer books covered more transient topicsoperating systems, applications software, security, communications technology, and hardware configurations. Rapid changes in computer hardware and software technology during the 1980s and 1990s necessitated frequent changes and updates to these topics.
Also during that period hundreds of books about software testing were published. They, too, took a more transient approach to the topic. The Art of Software Testing alone gave the industry a long-lasting, foundational guide to one of the most important computer topics: How do you ensure that all of the software you produce does what it was designed to do, andjust as importantdoesn't do what it isn't supposed to do?
The edition you are reading today retains the foundational philosophy laid by Myers more than three decades ago. But we have updated the examples to include more current programming languages, and we have addressed topics that were not yet topics when Myers wrote the first edition: Web programming, e-commerce, Extreme (Agile) programming and testing, and testing applications for mobile devices.
Along the way, we never lost sight of the fact that a new classic must stay true to its roots, so our version also offers you a software testing philosophy, and a process that works across current and unforeseeable future hardware and software platforms. We hope that the third edition of The Art of Software Testing , too, will span a generation of software designers and developers.
Introduction
At the time this book was first published, in 1979, it was a well-known rule of thumb that in a typical programming project approximately 50 percent of the elapsed time and more than 50 percent of the total cost were expended in testing the program or system being developed.
Today, a third of a century and two book updates later, the same holds true. There are new development systems, languages with built-in tools, and programmers who are used to developing more on the fly. But testing continues to play an important part in any software development project.
Given these facts, you might expect that by this time program testing would have been refined into an exact science. This is far from the case. In fact, less seems to be known about software testing than about any other aspect of software development. Furthermore, testing has been an out-of-vogue subject; it was so when this book was first published and, unfortunately, this has not changed. Today there are more books and articles about software testingmeaning that, at least, the topic has greater visibility than it did when this book was first publishedbut testing remains among the dark arts of software development.
This would be more than enough reason to update this book on the art of software testing, but we have additional motivations. At various times, we have heard professors and teaching assistants say, Our students graduate and move into industry without any substantial knowledge of how to go about testing a program. Moreover, we rarely have any advice to offer in our introductory courses on how a student should go about testing and debugging his or her exercises.
Thus, the purpose of this updated edition of The Art of Software Testing is the same as it was in 1979 and in 2004: to fill these knowledge gaps for the professional programmer and the student of computer science. As the title implies, the book is a practical, rather than theoretical, discussion of the subject, complete with updated language and process discussions. Although it is possible to discuss program testing in a theoretical vein, this book is intended to be a practical, both feet on the ground handbook. Hence, many subjects related to program testing, such as the idea of mathematically proving the correctness of a program, were purposefully excluded.
Chapter 1 assigns a short self-assessment test that every reader should take before reading further. It turns out that the most important practical information you must understand about program testing is a set of philosophical and economic issues; these are discussed in Chapter 2. Chapter 3 introduces the important concept of noncomputer-based code walkthroughs, or inspections. Rather than focus attention on the procedural or managerial aspects of this concept, as most such discussions do, this chapter addresses it from a technical, how-to-find-errors point of view.