Prefaceii
1 Introduction1
1.1 The Software Industry1
1.1.1 Software Testing and Quality2
1.1.2 Software Testing and Risk Management3
1.2 Mistakes, Faults and Failures3
1.2.1 Software Faults4
1.2.2 Software Failures5
1.2.3 Need for Testing6
1.3 The Role of Specifications8
1.4 Overview of Testing9
1.4.1 Testing in the Development Process9
1.4.2 Test Automation9
1.5 The Theory of Testing10
1.5.1 Exhaustive Testing Example11
1.5.2 Implications11
1.5.3 When To Finish Testing12
1.6 Book Structure13
1.6.1 Order of Testing14
1.6.2 Programming Language14
1.6.3 Level of Detail14
1.6.4 Code Examples14
1.7 Notes on Terminology14
2 Principles of Software Testing15
2.1 Static Verification15
2.1.1 Walk-throughs16
2.1.2 Code Reviews/Inspections16
2.1.3 Formal Methods and Testing18
2.2 Dynamic Verification19
2.3 Black-Box and White-Box Testing19
2.3.1 Errors of “Omission” and “Commission” 21
2.4 Test Approaches22
2.4.1 Black-Box Testing22
2.4.2 White-Box Testing23
2.4.3 Fault Insertion24
2.5 Test Design Process24
2.5.1Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5.2Generating Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5.3Generating Test Data . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.4Implementing Tests . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.6 Analysis of Software Specifications . . . . . . . . . . . . . . . . . . . . . . 27
2.6.1Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6.2Parameter Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6.3Equivalence Partitions . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6.4Boundary Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.6.5Combinations of Values . . . . . . . . . . . . . . . . . . . . . . . . 30
2.6.6Sequences of Values . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.7 Analysis of Software Components . . . . . . . . . . . . . . . . . . . . . . 40
2.7.1Control Flow Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.7.2Decisions and Conditions . . . . . . . . . . . . . . . . . . . . . . . 43
2.7.3Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.7.4Data Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.8 Analysis of Targets for Fault Insertion . . . . . . . . . . . . . . . . . . . . 47
2.8.1Offutt’s 5 Sufficient Mutations . . . . . . . . . . . . . . . . . . . . 47
2.9 TestArtefacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3 Unit Testing50
3.1 Techniques50
3.2 Usage51
3.3 Black-Box Techniques52
3.3.1 Equivalence Partitioning (EP)52
3.3.2 Boundary Value Analysis (BVA)53
3.3.3 Testing Combinations of Inputs55
3.3.4 Testing Sequences of Inputs/State-Based Testing56
3.3.5 Testing with Random Data . . . . . . . . . . . . . . . . . . . . . . 56
3.3.6 Error Guessing/Expert Opinion . . . . . . . . . . . . . . . . . . . . 58
3.4White-Box Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.4.1Statement Coverage (SC) . . . . . . . . . . . . . . . . . . . . . . . 60
3.4.2 Branch Coverage (BC) . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.4.3 Condition Coverage (CC) . . . . . . . . . . . . . . . . . . . . . . 62
3.4.4 Decision Condition Coverage (DCC) . . . . . . . . . . . . . . . . . 64
3.4.5 Multiple Condition Coverage (MCC) . . . . . . . . . . . . . . . . .65
3.4.6 Modified Condition Decision Coverage (MCDC) . . . . . . . . . .66
3.4.7 Path Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.4.8 Dataflow Coverage (DU Pairs) . . . . . . . . . . . . . . . . . . . . 68
3.5 Fault Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.5.1 Strong Mutation Testing . . . . . . . . . . . . . . . . . . . . . . . . 69
3.6Test Ranking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4 Unit Testing Examples 71
4.1Example One: fits() . .