Introduction to Software Testing Chapter 4 Input Space Partition Testing Paul Ammann Jeff Offutt www introsoftwaretesting com Ch 4 Input Space Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Applied to Applied to Source Specs Source Specs Design Applied to FSMs DNF Source Integ Use cases Introduction to Software Testing Ch 4 www introsoftwaretesting com Models Ammann Offutt Input 2 1 Input Domains The input domain to a program contains all the possible inputs to that program For even small programs the input domain is so large that it might as well be infinite Testing is fundamentally about choosing finite sets of values from the input domain Input parameters define the scope of the input domain Parameters to a method Data read from a file Global variables User level inputs Domain for each input parameter is partitioned into regions At least one value is chosen from each region Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 3 Benefits of ISP Can be equally applied at several levels of testing Unit Integration System Relatively easy to apply with no automation Easy to adjust the procedure to get more or fewer tests No implementation knowledge is needed just the input space Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 4 2 Partitioning Domains Partition Domain D Partition scheme q of D The partition q defines a set of blocks Bq b1 b2 bQ The partition must satisfy two properties 1 blocks must be pairwise disjoint no overlap 2 together the blocks cover the domain D complete b1 b2 bi bj i j bi bj Bq b3 b D b Bq Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 5 Using Partitions Assumptions Choose a value from each partition Each value is assumed to be equally useful for testing Application to testing Find characteristics in the inputs parameters semantic descriptions Partition each characteristics Choose tests by combining values from characteristics Characteristics Input X is null Order of the input file F sorted inverse sorted arbitrary Min separation of two aircraft Input device DVD CD VCR computer Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 6 3 Choosing Partitions Choosing or defining partitions seems easy but is easy to get wrong Consider the order of file F b1 sorted in ascending order b2 sorted in descending order b3 arbitrary order but something s fishy What if the file is of length 1 The file will be in all three blocks That is disjointness is not satisfied Introduction to Software Testing Ch 4 www introsoftwaretesting com Solution Each characteristic should address just one property File F sorted ascending b1 true b2 false File F sorted descending b1 true b2 false Ammann Offutt 7 Properties of Partitions If the partitions are not complete or disjoint that means the partitions have not been considered carefully enough They should be reviewed carefully like any design attempt Different alternatives should be considered Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 8 4 Modeling the Input Domain Step 1 Identify testable functions Individual methods have one testable function In a class each method has the same characteristics Programs have more complicated characteristics modeling documents such as UML use cases can be used to design characteristics Systems of integrated hardware and software components can use devices operating systems hardware platforms browsers etc Step 2 Find all the parameters Often fairly straightforward even mechanical Important to be complete Methods Parameters and state non local variables used Components Parameters to methods and state variables System All inputs including files and databases Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 9 Modeling the Input Domain cont Step 3 Model the input domain The domain is scoped by the parameters The structure is defined in terms of characteristics Each characteristic is partitioned into sets of blocks Each block represents a set of values This is the most creative design step in applying ISP Step 4 Apply a test criterion to choose combinations of values A test input has a value for each parameter One block for each characteristic Choosing all combinations is usually infeasible Coverage criteria allow subsets to be chosen Step 5 Refine combinations of blocks into test inputs Choose appropriate values from each block Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 10 5 Input Domain Modeling Interface based approach Develops characteristics directly from individual input parameters Simplest application Can be partially automated in some situations Functionality based approach Develops characteristics from a behavioral view of the program under test Harder to develop requires more design effort May result in better tests or fewer tests that are as effective Input Domain Model IDM Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 11 Interface Based Approach Mechanically consider each parameter in isolation This is an easy modeling technique and relies mostly on syntax Some domain and semantic information won t be used Could lead to an incomplete IDM Ignores relationships among parameters Consider TriTyp from Chapter 3 Three int parameters IDM for each parameter is identical Reasonable characteristic Relation of side with zero Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 12 6 Functionality Based Approach Identify characteristics that correspond to the intended functionality Requires more design effort from tester Can incorporate domain and semantic knowledge Can use relationships among parameters Modeling can be based on requirements not implementation The same parameter may appear in multiple characteristics so it s harder to translate values to test cases Consider TriTyp again The three parameters represent a triangle IDM can combine all parameters Reasonable characteristic Type of triangle Introduction to Software Testing Ch 4 www introsoftwaretesting com Ammann Offutt 13 Steps 1 2 Identifying Functionalities Parameters and Characteristics A creative engineering step More characteristics means more tests Interface based Translate parameters to characteristics Candidates for characteristics Preconditions and postconditions Relationships among variables Relationship of variables
View Full Document
Unlocking...