Black Box testing Exercises Lecturer: Giuseppe Santucci
Exercise 1 A software program for the simulation of scuba diving with special gas mixture gives indication about maximum time of stay on the bottom, based on a) percentage of oxygen present in the mixture and b) the maximum depth. The software takes as input the percentage of oxygen: acceptable values are 21..36 % maximum depth: acceptable values are 10..50 meters Gives as output An integer that corresponds to the maximum duration of the immersion at that depth expressed in minutes. Design, based on black-box techniques, test cases for this functionality. Consider that based on the specification document, if the percentage of oxygen is more than 30%, the maximum acceptable depth is 40 meters.
Identify equivalent classes Classes have to be listed and each has to be assigned a unique ID Useful criteria for defining the equivalent classes are Intervals of values Number of values Sets of values Constraints Format errors
Intervals of values VC1 oxygen interval [21,36] IC2 oxygen <21 IC3 oxygen >36 VC4 depth interval [10,50] IC5 depth <10 IC6 depth >50
Number of values VC7 IC8 IC9 2 integers as input < 2 integers as input > 2 integers as input IC10 IC11 format error on the first input data format error on the second input data
Constraints VC12 if oxygen > 30 then depth <= 40 IC13 if oxygen > 30 then depth > 40
Test cases necessary for covering the equivalent classes Test case Covered classes Oxygen depth Expected result/behavior T1: 31 35 (VC1, VC4, VC7, VC12) : an integer T2: 10 35 (IC2 oxygen<21) : oxygen too low T3: 41 35 (IC3 oxygen>36) : oxygen too high T4: 31 5 (IC5 depth<10) : depth too low T5: 29 55 (IC6 depth>50) : depth too high T6: 31 (IC8 less than 2 int) : too few input data T7: 31 35 22 (IC9 more than 2 int) : too many input data T8: 33.0 35 (IC10) : oxygen format error T9: 31 23.0 (IC11) : depth format error T10: 35 45 (IC13 ) : depth too high wrt oxygen
Boundary value analysis Intervals of input data Design test cases Equal to the boundary values Immediately above the boundary values Immediately below the boundary values For valid classes (one at a time) T11: 20 30 ; 21 30; 22 30 ; 35 30 ; 36 30 ; 37 30 (VC1 oxygen [21,36]) T12: 25 9 ; 25 10 ; 25 11 ; 25 49 ; 25 50 ; 25 51 (VC4 depth [10,50])
Boundary value analysis Number of input data Design test cases For the minimum number of values For the maximum number of values A number of values immediately below the minimum A number of values immediately above the maximum In this case maximum and minimum coincide (2) and we already tested 1 2 and 3 (T6, T1, T7)
Boundary value analysis Constrains Design test cases That satisfy the condition Immediately above Immediately below This activity makes sense only for constraints based on numerical comparisons, e.g. less than If oxygen > 30 then depth <= 40 Minimum value that makes the if condition true: 31 -> 30, 31, and 32 Maximum value that makes the then condition true : 40 -> 39, 40, and 41 30 39 ; 30 40 ; 30 41 31 39 ; 31 40 ; 31 41 32 39 ; 32 40 ; 32 41 Error
Boundary value analysis Intervals related to output We don t known what is the rule that relates input with output However, it makes sense to test the minimum value for the two inputs T11: 21 10 And the maximum values: T12: 36 40 T13: 30 50
Exercise 2 A web application for hotel booking takes as input the number of people that need the room (min 3), the arrival date, the departure date (must be after at most 15 days) and the room type (smoking/non-smoking) Dates must be entered in the dd/mm/yy format Codes for smoking is s, code for non-smoking is ns Design test cases for such functionality based on black box testing technique. Indicate what techniques are used and the identified equivalent classes.
Identify equivalent classes Classes have to be listed and each has to be assigned a unique ID Useful criteria for defining the equivalent classes are Intervals of values Number of values Sets of values Constraints
Intervals of values VC1 people [3,5] (arbitrary) IC2 people < 3 IC3 people >5
Number of values VC4 4 input arguments IC5 less than 4 input arguments IC6 more than 4 input arguments IC7 format error on people data IC8 format error on arrival date IC9 format error on departure date IC10 format error on room type
Sets of values VC11 room type = s VC12 room type = ns IC13 room type { s, ns }
Constraints VC14 data_out - data_in <= 15 VC15 data_out - data_in > 0 IC16 data_out - data_in >15 IC17 data_out - data_in <= 0
Test cases necessary for covering the equivalent classes T1:4,3/10/04, 5/10/04, s (VC1,VC4,VC11,VC14,VC15):OK T2:4,3/10/04, 5/10/04, ns (VC12): OK T3:2,3/10/04, 5/10/04, s (IC2): too few people T4:6,3/10/04, 5/10/04, ns (IC3): too many people T5:4,3/10/04, 5/10/04 (IC5): too few inputs T6:4,3/10/04, 5/10/04, s, 5 (IC6): too many inputs T7:4.0,3/10/04, 5/10/04, s (IC7): format error on people T8:4,3/october/04, 5/10/04, s (IC8): format error data_in T9:4,3/10/04, 5/october/04, s (IC9): format error data_out T10:4,3/10/04, 5/10/04, 1 (IC10, IC13): format err room type T11:4,3/10/04, 5/10/04, veg (IC13): error room type T12:4,3/10/04, 25/10/04, s (IC16): too many days T12:4,3/10/04, 3/10/04, s (IC17): too few days
Boundary value analysis Intervals related to input data people [3,5]--> 2,3,4 & 4,5,6 Design test cases Equal to the boundary values Immediately above the boundary values Immediately below the boundary values For valid classes (one at a time) Error T13: 2,3/10/04, 5/10/04, s 3,3/10/04, 5/10/04, s 4,3/10/04, 5/10/04, s 4,3/10/04, 5/10/04, s 5,3/10/04, 5/10/04, s 6,3/10/04, 5/10/04, s
Boundary value analysis Number of input data Design test cases For the minimum number of values For the maximum number of values A number of values immediately below the minimum A number of values immediately above the maximum In this case maximum and minimum coincide (4) and we already tested 3 4 and 5 (T5, T1, T6)
Boundary value analysis Constrains Design test cases That satisfy the condition Immediately above Immediately below data_out - data_in <= 15 : maximum value making the condition true: 15 data_out - data_in = 14 data_out - data_in = 15 data_out - data_in = 16 T14: 4, 3/10/04, 17/10/04, s T15: 4, 3/10/04, 18/10/04, s T16: 4, 3/10/04, 19/10/04, s Error
Boundary value analysis Constrains Design test cases That satisfy the condition Immediately above Immediately below data_out-data_in > 0 data_out - data_in = -1 (additional case for negative values) data_out - data_in = 0 data_out - data_in = 1 data_out - data_in = 2 T17: 4, 3/10/04, 2/10/04, s T18: 4, 3/10/04, 3/10/04, s T19: 4, 3/10/04, 4/10/04, s T20: 4, 3/10/04, 5/10/04, s Error