Sei sulla pagina 1di 10

SOFTWARE TESTING

A Craftsmcm's Approach
THIRD EDITION

Paul C. Jorgensen

Auerbach Publications
Taylor &. Francis C r o u p
Boca Raton N e w York

Auerbach Publications is an imprint of the Taylor & Francis Group, an informa business

Contents
Preface to the Third Edirion Preface to the Second Edition Preface to the First Edition The Author xvii xix xxi xxiii

PART I: A MATHEMATICAL CONTEXT


1 A Perspective on Testing 1.1 Basic Definitions 1.2 Test Cases 1.3 Insights from a Venn Diagram 1.4 Identifying Test Cases 1.4.1 Functional Testing 1.4.2 Structural Testing 1.4.3 The Functional versus Structural Debate 1.5 Error and Fault Taxonomies 1.6 Levels of Testing References Exercises Examples 2.1 Generalized Pseudocode 2.2 The Triangle Problem 2.2.1 Problem Statement 2.2.2 Discussion 2.2.3 Traditional Implementation 2.2.4 Structured Implementation 2.3 The NextDate Function 2.3.1 Problem Statement 2.3.2 Discussion 2.3.3 Implementation 2.4 The Commission Problem 2.4.1 Problem Statement 2.4.2 Discussion 2.4.3 Implementation 3 3 5 6 7 7 8 9 10 12 13 14 15 15 16 16 17 17 19 22 22 22 23 26 26 26 26 vii

viii

Contents

2.5

The SATM System 2.5.1 Problem Statement 2.5.2 Discussion 2.6 The Currency Converter 2.7 Saturn Windshield Wiper Controller References Exercises

27 28 30 30 31 31 31 33 33 34 34 35 35 36 37 38 39 39 40 40 41 42 43 44 45 45 46 47 47 49 49 51 51 52 53 53 54 55 55 56 56 57 58 58 59 59

Discrete Math for Testers 3.1 Set Theory 3.1.1 Set Membership 3.1.2 Set Definition 3.1.3 The Empty Set 3.1.4 Venn Diagrams 3.1.5 Set Operations 3.1.6 Set Relations 3.1.7 Set Partitions 3.1.8 Set Identities 3.2 Functions 3.2.1 Domain and Range 3.2.2 Function Types 3.2.3 Function Composition 3.3 Relations 3.3.1 Relations among Sets 3.3.2 Relations on a Single Set., 3.4 Propositional Logic 3.4.1 Logical Operators 3.4.2 Logical Expressions 3.4.3 Logical Equivalence 3.5 Probability Theory Reference Exercises Graph Theory for Testers 4.1 Graphs 4.1.1 Degree of a Node 4.1.2 Incidence Matrices 4.1.3 Adjacency Matrices 4.1.4 Paths 4.1.5 Connectedness 4.1.6 Condensation Graphs 4.1.7 Cyclomatic Number 4.2 Directed Graphs 4.2.1 Indegrees and Outdegrees 4.2.2 Types ofNodes 4.2.3 Adjacency Matrix of a Directed Graph 4.2.4 Paths and Semipaths 4.2.5 Reachability Matrix

Contents

ix

4.2.6 n-Connectedness 4.2.7 Strong Components 4.3 Graphs for Testing 4.3.1 Program Graphs 4.3.2 Finite State Machines 4.3.3 Petri Nets 4.3.4 Event-Driven Petri Nets 4.3.5 StateCharts References Exercises

60 60 62 62 63 64 61 69 72 72

PART II: FUNCTIONAL TESTING


5 Boundary Value Testing 5.1 Boundary Value Analysis 5.1.1 Generalizing Boundary Value Analysis 5.1.2 Limitations of Boundary Value Analysis 5.2 Robustness Testing 5.3 Worst-Case Testing 5.4 Special Value Testing 5.5 Examples 5.5.1 Test Cases for the Triangle Problem 5.5.2 Test Cases for the NextDate Function 5.5.3 Test Cases for the Commission Problem 5.6 Random Testing 5.7 Guidelines for Boundary Value Testing Exercises Equivalence Class Testing 6.1 Equivalence Classes 6.1.1 Weak Normal Equivalence Class Testing 6.1.2 Strong Normal Equivalence Class Testing 6.1.3 Weak Robust Equivalence Class Testing 6.1.4 Strong Robust Equivalence Class Testing 6.2 Equivalence Class Test Cases for the Triangle Problem 6.3 Equivalence Class Test Cases for the NextDate Function 6.3.1 Equivalence Class Test Cases 6.4 Equivalence Class Test Cases for the Commission Problem 6.4.1 Output Range Equivalence Class Test Cases 6.5 Guidelines and Observations References Exercises Decision Table-Based Testing 7.1 Decision Tables 7.1.1 Technique 7.2 Test Cases for the Triangle Problem 75 75 76 77 78 79 80 80 81 82 82 84 86 87 89 89 90 91 91 92 93 95 97 98 100 101 101 101 103 103 104 108

Contents

Test Cases for the NextDate Function 7.3.1 First Try 73.2 SecondTry 7.3.3 Third Try 7.4 Test Cases for the Commission Problem 7.5 Guidelines and Observations References Exercises 8 Retrospective on Functional Testing 8.1 Testing Effort 8.2 Testing Efficiency 8.3 Testing Effectiveness 8.4 Guidelines 8.5 Case Study

7.3

109 109 110 111 114 114 115 115 117 117 120 121 122 123

PART III: STRUCTURAL TESTING


9 Path Testing 9.1 DD-Paths 9.2 Test Coverage Metrics 9.2.1 Metric-Based Testing 9.2.2 Test Coverage Analyzers 9.3 Basis Path Testing 9.3.1 McCabe's Basis Path Method 9.3.2 Observations on McCabe's Basis Path Method 9.3.3 Essential Complexity 9.4 Guidelines and Observations References Exercises Dataflow Testing 10.1 Define/Use Testing 10.1.1 Example 10.1.2 du-Paths for Stocks 10.1.3 du-Paths for Locks 10.1.4 du-Paths for totalLocks 10.1.5 du-Paths for Sales 10.1.6 du-Paths for Commission 10.1.7 du-Path Test Coverage Metrics 10.2 Slice-Based Testing 10.2.1 Example 10.2.2 Style and Technique 10.3 Guidelines and Observations References Exercises 131 132 136 137 139 139 139 142 143 146 148 148 151 152 153 156 156 156 157 158 160 161 162 165 166 167 167

10

Contents

xi

11

Retrospective on Structural Testing 11.1 Gaps and Redundancies 11.2 Metrics for Method Evaluation 11.3 Case Study Revisited 11.3.1 Path-Based Testing 11.3.2 Dataflow Testing 11.3.3 Slice Testing References Exercises

169 170 172 174 175 177 177 177 178

PART IV: INTEGRATION AND SYSTEM TESTING


12 Levels of Testing 12.1 Traditional View of Testing Levels 12.2 Alternative Life Cycle Models 12.2.1 Waterfall Spin-Offs 12.2.2 Specification-Based Life Cycle Models 12.3 Tfie SATM System 12.4 Separating Integration and System Testing 12.4.1 Structural Insights 12.4.2 Behavioral Insights References Integration Testing 13.1 A Closer Look at the SATM System 13.2 Decomposition-Based Integration 13.2.1 Top-Down Integration 13.2.2 Bottom-Up Integration 13.2.3 Sandwich Integration 13.2.4 Pros and Cons 13.3 Call Graph-Based Integration 13.3.1 Pairwise Integration 13.3.2 Neighborhood Integration 13.3.3 Pros and Cons 13.4 Path-Based Integration 13.4.1 New and Extended Concepts 13.4.2 MM-Paths in the SATM System 13.4.3 MM-Path Complexity 13.4.4 Pros and Cons 13.5 Case Study 13.5.1 Decomposition-Based Integration 13.5.2 Call Graph-Based Integration 13.5.3 MM-Path-Based Integration References Exercises 181 181 183 183 184 186 196 197 198 199 201 203 205 206 207 208 208 209 209 210 212 212 213 216 220 220 221 225 225 226 227 227

13

xii

Contents

14

System Testing 14.1 Threads 14.1.1 Thread Possibilities 14.1.2 Thread Definitions 14.2 Basis Concepts for Requirements Specification 14.2.1 Data 14.2.2 Actions 14.2.3 Devices 14.2.4 Events 14.2.5 Threads 14.2.6 Relationships among Basis Concepts 14.2.7 Modeling with Basis Concepts 14.3 Finding Threads 14.4 Structural Strategies for Thread Testing 14.4.1 Bottom-Up Threads 14.4.2 Node and Edge Coverage Metrics 14.5 Functional Strategies for Thread Testing 14.5.1 Event-Based Thread Testing 14.5.2 Port-Based Thread Testing 14.5.3 Data-Based Thread Testing 14.6 SATM Test Threads 14.7 System Testing Guidelines 14.7.1 Pseudostructural System Testing 14.7.2 Operational Profiles 14.7.3 Progression vs. Regression Testing 14.8 ASF Testing Example References Exercises Interaction Testing 15.1 Context of Interaction 15.2 ATaxonomy of Interactions 15.2.1 Static Interactions in a Single Processor 15.2.2 Static Interactions in Multiple Processors 15.2.3 Dynamic Interactions in a Single Processor 15.2.4 Dynamic Interactions in Multiple Processors 15.3 Interaction, Composition, and Determinism 15.4 Client/Server Testing References Exercises

229 229 230 231 233 233 233 234 234 234 235 235 237 240 240 242 244 244 246 246 248 253 253 254 256 257 259 259 261 261 263 264 265 266 271 277 280 281 282

15

PART V: OBJECT-ORIENTED TESTING


16 Issues in Object-Oriented Testing 16.1 Units for Object-Oriented Testing 16.2 Implications of Composition and Encapsulation 285 286 286

Contents

xiii

Implications of Inheritance Implications of Polymorphism Levels of Object-Oriented Testing GUI Testing Dataflow Testing for Object-Oriented Software Examples for Part V 16.8.1 The Object-Oriented Calendar 16.8.2 The Currency Conversion Application References Exercises 17 Class Testing 17.1 Methods as Units 17.1.1 Pseudocode for o-oCalendar 17.1.1.1 Class: CalendarUnit 17.1.1.2 Class: testlt 17.1.1.3 Class: Date 17.1.1.4 Class: Day 17.1.1.5 Class: Month 17.1.1.6 Class: Year.... 17.1.2 Unit Testing for Date.increment 17.2 Classes as Units 17.2.1 Pseudocode for the windshieldWiper Class 17.2.2 Unit Testing for the windshieldWiper Class Object-Oriented Integration Testing 18.1 U M L Support for Integration Testing 18.2 MM-Paths for Object-Oriented Software 18.2.1 Pseudocode for o-oCalendar 18.3 A Framework for Object-Oriented Dataflow Integration Testing 18.3.1 Event- and Message-Driven Petri Nets 18.3.2 Inheritance-Induced Dataflow 18.3.3 Message-Induced Dataflow 18.3.4 Slices? Reference Exercises GUI Testing 19.1 The Currency Conversion Program 19.2 Unit Testing for the Currency Conversion Program 19.3 Integration Testing for the Currency Conversion Program 19.4 System Testing for the Currency Conversion Program Exercises Object-Oriented System Testing 20.1 Currency Converter U M L Description 20.1.1 Problem Statement 20.1.2 System Functions

16.3 16.4 16.5 16.6 16.7 16.8

288 289 289 289 290 290 290 291 296 296 297 297 298 300 300 301 301 302 303 304 304 304 305 311 311 313 314 321 321 323 323 323 324 324 327 327 327 328 330 336 337 337 337 338

18

19

20

xiv

Contents

20.1.3 Presentation Layer 20.1.4 High-Level Use Cases 20.1.5 Essential Use Cases 20.1.6 Detailed GUI Definition 20.1.7 Expanded Essential Use Cases 20.1.8 Real Use Cases 20.2 UML-Based System Testing 20.3 StateChart-Based System Testing References

338 339 339 341 341 346 346 349 349

PART VI: MILLENNIUM TESTING


21 Exploratory Testing 21.1 The Context-Driven School 21.2 Exploring Exploratory Testing 21.3 Exploring a Familir Example 21.4 Exploratory and Context-Driven Testing Observations References Exercises Model-Based Testing 22.1 Testing Based on Models 22.2 Appropriate Models 22.2.1 Peterson's Lattice 22.2.2 Expressive Capabilities of Mainline Models 22.2.3 Making Appropriate Choices 22.3 Use Case-Based Testing 22.3.1 Deriving Test Cases from Use Cases 22.3.2 Interacting Use Cases 22.3.3 How Many Use Cases? 22.4 Commercial Tool Support for Model-Based Testing References Test-Driven Development 23.1 Test-Then-Code Cycles 23.2 Automated Test Execution (Testing Frameworks) 23.3 Java andJUnit Example 23.3.1 Java Source Code 23.3.2 JUnit Test Code 23.4 Remaining Questions 23.4.1 Specification Based or Code Based? 23.4.2 Configuration Management? 23.4.3 Granularity? 23.5 Pros, Cons, and Open Questions of TDD 23.6 Retrospective on MDD versus TDD 353 353 354 356 358 358 359 361 361 362 362 363 363 364 365 365 367 367 368 369 369 378 379 379 382 383 383 384 385 385 386

22

23

Contents

xv

24

A Closer Look at All Pairs Testing 24.1 The All Pairs Technique 24.1.1 Program Inputs 24.1.2 Independent Variables 24.1.3 Input Order 24.1.4 Failures Due Only to Pairs of Inputs 24.2 A Closer Look at the NIST Study 24.3 Appropriate Applications for All Pairs Testing 24.4 Recommendations for All Pairs Testing References Epilogue: Software Testing Excellence 25.1 Craftsmanship 25.2 Best Practices of Software Testing 25.3 Top 10 Best Practices for Software Testing Excellence 25.3.1 Model-Driven Development 25.3.2 Careful Definition and Identification of Levels of Testing 25.3.3 System-Level Model-Based Testing 25.3.4 System Testing Extensions 25.3.5 Incidence Matrices to Guide Regression Testing 25.3.6 Use of MM-Paths for Integration Testing 25.3.7 Intelligent Combination of Specification-Based and Code-Based Unit-Level Testing 25.3.8 Code Coverage Metrics Based on the Nature of Individual Units 25.3.9 Exploratory Testing during Maintenance 25.3.10 Test-Driven Development 25.4 Mapping Best Practices to Diverse Projects 25.4.1 A Mission-Critical Project 25.4.2 A Time-Critical Project 25.4.3 Corrective Maintenance of Legacy Code Reference Index,

391 391 392 394 396 397 399 400 401 401 403 403 404 405 405 406 406 406 406 406 407 407 407 407 407 407 407 408 408 409

25

Potrebbero piacerti anche