Subject Name Software Testing Subject Code 10 CS
Subject Name: Software Testing Subject Code: 10 CS 842 Prepared By: Tamilarasi. R Department: CSE Date 12/5/2020
Unit –II Boundary Value Testing, Equivalence Class Testing, Decision Table-Based Testing 12/5/2020
• • • Topics Boundary value analysis Robustness testing Worst-case testing Special value testing Examples, Random testing, Equivalence classes, Equivalence test cases for the triangle problem, Next Date function, and the commission problem, Guidelines and observations. Decision tables, Test cases for the triangle problem, Next Date function, and the commission problem, Guidelines and observations. 12/5/2020
Boundary Value Analysis • Boundary value analysis focuses on the boundary of the input space to identify test cases. • The rationale behind boundary value analysis is that errors tend to occur near the extreme values of an input variable. • Programs written in non-strongly typed languages are more appropriate candidates for boundary value testing. • In our discussion we will assume a program P accepting two inputs x 1 andx 2 such that a ≤ y 1 ≤ b and c ≤ y 2 ≤ d 4
Valid Input for Program P • consider the following function: • boundary inequalities of n input variables define an ndimensional input space: 5
Value Selection in Boundary Value Analysis • The basic idea in boundary value analysis is to select input variable values at their: – Minimum – Just above the minimum – A nominal value – Just below the maximum – Maximum 6
Single Fault Assumption • Boundary value analysis is also augmented by the single fault assumption principle. “Failures occur rarely as the result of the simultaneous occurrence of two (or more) faults” • In this respect, boundary value analysis test cases can be obtained by holding the values of all but one variable at their nominal values, and letting that variable assume its extreme values. 7
Boundary Value Analysis for Program P . . . T = { <y 1 nom, y 2 min>, <y 1 nom, y 2 min+>, <y 1 nom, y 2 nom>, <y 1 nom, y 2 max->, <y 1 nom, y 2 max+>, <y 1 min, y 2 nom>, < 1 nin+, y 2 nom>, <y 1 max-, y 2 nom>, <y 1 max, y 2 nom> } 8
Example Test Cases Using Boundary Value Analysis Case # a b c Expected Output 1 100 1 Isosceles 2 100 2 Isosceles 3 100 100 Equilateral 4 100 199 Isosceles 5 100 200 Not a Trianle 6 100 1 100 Isosceles 7 100 2 100 Isosceles 8 100 100 Equilateral 9 100 199 100 Isosceles 10 100 200 100 Not a Triangle 11 1 100 Isosceles 12 2 100 Isosceles 13 100 100 Equilateral 14 199 100 Isosceles 15 200 100 Not a Triangle 9
Generalizing Boundary Value Analysis • The basic boundary value analysis can be generalized in two ways: – By the number of variables - (4 n +1) test cases for n variables – By the kinds of ranges of variables • Programming language dependent • Bounded discrete • Unbounded discrete (no upper or lower bounds clearly defined) • Logical variables 10
Limitations of Boundary Value Analysis • Boundary value analysis works well when the program to be tested is a function of several independent variables that represent bounded physical quantities. • Boundary value analysis selected test data with no consideration of the function of the program, nor of the semantic meaning of the variables. • We can distinguish between physical and logical type of variables as well (e. g. temperature, pressure speed, or PIN numbers, telephone numbers etc. ) 11
Independence Assumption and Efficacy of BVT • Assumes that input variables are independent of one another, – i. e. the assumption that particular combinations of input variable values have no special significance • If basic assumption is not true, then BVT may overlook important test requirements • BVT is an instance of more general techniques such as equivalence class testing or domain testing. • BVT tends to generate more test cases with poorer test coverage (with the independence assumption) than domain or equivalence testing. • But, due to its simplicity, BVT test case generation can be easily automated. 12
Robustness Testing • Robustness testing is a simple extension of boundary value analysis. • In addition to the five boundary value analysis values of variables, we add values slightly greater that the maximum (max+) and a value slightly less than the minimum (min-). • The main value of robustness testing is to force attention on exception handling. • In some strongly typed languages values beyond the predefined range will cause a run-time error. • It is a choice of using a weak typed language with exception handling or a strongly typed language with explicit logic to handle out of range values. 13
Robustness Test Cases for Program P . . . . . … . . 14
Worst Case Testing • In worst case testing we reject the single fault assumption ans we are interested what happens when more than one variable has an extreme value. • Considering that we have five different values that can be considered during boundary value analysis testing for one variable, now we take the Cartesian product of these possible values for 2, 3, … n variables. • In this respect we can have 5 n test cases for n input variables. • The best application of worst case testing is where physical variables have numerous interactions and failure of a program is costly. • Worst case testing can be further augmented by considering robust worst case testing (i. e. adding slightly out of bounds values to the five already considered). 15
Worst Case Testing for Program P . . . 16
Robust Worst Case Testing for Program P . . . . … 17
Special Value Testing • Special value testing is probably the most widely practiced form of functional testing, most intuitive, and least uniform. • Utilizes domain knowledge and engineering judgment about program’s “soft spots” to devise test cases. • Event though special value testing is very subjective on the generation of test cases, it is often more effective on revealing program faults. 18
Guidelines for Boundary Value Testing • With the exception of special value testing, the test methods based on the boundary values of a program are the most rudimentary. • Issues in producing satisfactory test cases using boundary value testing: – Truly independent variables versus not independent variables – Normal versus robust values – Single fault versus multiple fault assumption • Boundary value analysis can also be applied to the output range of a program (i. e. error messages), and internal variables (i. e. loop control variables, indices, and pointers). 19
The Commission Problem • Rifle salespersons in the Arizona Territory sold rifle locks, stocks, and barrels made by a gunsmith in Missouri • Lock = $45. 00, stock = $30. 00, barrel = $25. 00 • Each salesperson had to sell at least one complete rifle per month ($100) • The most one salesperson could sell in a month was 70 locks, 80 stocks, and 90 barrels • Each salesperson sent a telegram to the Missouri company with the total order for each town (s)he visits • 1≤towns visited≤ 10, per month • Commission: 10% on sales up to $1000, 15% on the next $800, and 20% on any sales in excess of $1800 20
Example Test Cases Using Output Range Values Barrels 90 72 40 Locks 70 22. 2 60 33. 3 Stocks 60 80 21
Output Boundary Value Test Cases Case # Locks Stocks Barrels Sales Comments 1 1 100 10 min 2 10 10 9 975 97. 5 border- 3 10 970 97 border- 4 9 10 10 955 95. 5 border- 5 10 1000 100 border 6 10 10 11 1025 103. 75 border+ 7 10 11 10 1030 104. 5 border+ 8 11 10 10 1045 106. 75 border+ 22
Output Special Value Test Cases Case # Locks Stocks Barrels Sales Comment 1 10 11 9 1005 100. 75 border+ 2 18 17 19 1795 219. 25 border+ 3 18 19 17 1805 221 border+ 23
Random testing • • 12/5/2020 Random testing is a black-box software testing technique where programs are tested by generating random, independent inputs. Results of the output are compared against software specifications to verify that the test output is pass or fail. In case of absence of specifications the exceptions of the language are used which means if an exception arises during test execution then it means there is a fault in the program.
Equivalence Classes • • In mathematics, when a set has an equivalence relation defined on its elements, there is a natural grouping of elements that are related to one another, forming what are called equivalence classes. An equivalence relation is a binary relation ~ satisfying three properties: For every element a in X, a ~ a (reflexivity), For every two elements a and b in X, if a ~ b, then b ~ a (symmetry) For every three elements a, b, and c in X, if a ~ b and b ~ c, then a ~ c (transitivity). The equivalence class of an element a is denoted [a] and is defined as the set of elements that are related to a by ~. 12/5/2020
Equivalence Class Test Cases for the Triangle Problem • Outputs: Not a Triangle, Scalene, Isosceles, Equilateral • Easier to identify output (range) equivalence classes – – R 1 = {<a, b, c> : the triangle with sides a, b, and c is equilateral} R 2 = {<a, b, c> : the triangle with sides a, b, and c is isosceles} R 3 = {<a, b, c> : the triangle with sides a, b, and c is scalene} R 4 = {<a, b, c> : sides a, b, and c do not form a triangle} 26
Equivalence Class Test Cases for the Triangle Problem • Input (domain) equivalence classes D 1 = {<a, b, c> : a = b = c} D 2 = {<a, b, c> : a = b, a ≠ c} D 3 = {<a, b, c> : a = c, a ≠ b} D 4 = {<a, b, c> : b = c, a ≠ b} D 5 = {<a, b, c> : a ≠ b, a ≠ c, b ≠ c} // D 6 = {<a, b, c> : a ≥ b + c} D 6’ = {<a, b, c> : a = b + c} D 6’’ = {<a, b, c> : a > b + c} // D 7 = {<a, b, c> : b ≥ a + c} D 7’ = {<a, b, c> : b = a + c} D 7’’ = {<a, b, c> : b > a + c} // D 8 = {<a, b, c> : c ≥ a + b} D 8’ = {<a, b, c> : c = a + b} D 8’’ = {<a, b, c> : c > a + b} 27
Equivalence Class Test Cases for the Next. Date Function • Input variables – 1 ≤ month ≤ 12 – 1 ≤ day ≤ 31 – 1812 ≤ year ≤ 2012 • Traditional approach – Valid equivalence classes • M 1 = { month : 1 ≤ month ≤ 12 } • D 1 = { day : 1 ≤ day ≤ 31 } • Y 1 = { year : 1812 ≤ year ≤ 2012 } – Invalid equivalence classes • • • M 2 = { month : month < 1 } M 3 = { month : month > 12 } D 2 = { day : day < 1 } D 3 = { day : day >31 } Y 2 = { year : year < 1812 } Y 3 = {year : year > 2012 } 28 University of Waterloo
Equivalence Class Test Cases for the Next. Date Function • Traditional approach is deficient because it “treats” the elements of a class at the valid/invalid level • Different approach: What must be done to an input date? M 1 = { month: month has 30 days } M 2 = { month: month has 31 days } M 3 = { month: month is February } D 1 = { day: 1 ≤ day ≤ 28 } D 2 = { day: day = 29 } D 3 = { day: day = 30 } D 4 = { day: day = 31 } Y 1 = { year: year = 1900 } Y 2 = { year: 1812 ≤ year ≤ 2012 AND (year ≠ 1900) AND (year mod 4 = 0) } Y 3 = { year: 1812 ≤ year ≤ 2012 AND (year mod 4 ≠ 0) } Not a perfect set of equivalence classes!!! 29 Universi
Equivalence Class Test Cases for the Next. Date Function Weak equivalence class test cases Strong equivalence class test cases 30
Equivalence Class Test Cases for the Commission Problem • Input Domain Equivalence Classes – Lock • L 1 = { lock: 1 ≤ lock ≤ 70 } • L 2 = { lock: lock < 1 } • L 3 = { lock: lock > 70 } – Stock • S 1 = { stock: 1 ≤ stock ≤ 80 } • S 2 = { stock: stock < 1 } • S 3 = { stock: stock > 80 } – Barrel • B 1 = { barrel: 1 ≤ barrel ≤ 90 } • B 2 = { barrel: barrel < 1 } • B 3 = { barrel: barrel > 90 } SE 465/ECE 453 31 University of Waterloo
Equivalence Class Test Cases for the Commission Problem Strong Input Domain Equivalence Class Test Cases Weak Input Domain Equivalence Class Test Cases 32
Equivalence Class Test Cases for the Commission Problem • • sales = 45 x locks + 30 x stocks + 25 x barrels L 1 = { <lock, stock, barrel> : sales ≤ 1000 } L 2 = { <lock, stock, barrel> : 1000 < sales ≤ 1800 } L 3 = { <lock, stock, barrel> : sales > 1800 } Output Range Equivalence Class Test Cases 33
Guidelines and Observations 1. 2. 3. 4. The traditional form of equivalence class testing is generally not as thorough as weak equivalence class testing, which in turn, is not as thorough as the strong form of equivalence class testing The only time it makes sense to use the traditional approach is when the implementation language is not strongly typed If error conditions are a high priority, we could extend strong equivalence class testing to include invalid classes (e. g. commission problem) Equivalence class testing is appropriate when input data is defined in terms of ranges and sets of discrete values. This is certainly the case when system malfunctions can occur for out-of-limit variable values 34 University of Waterloo
Guidelines and Observations 1. 2. 3. Equivalence class testing is strengthened by a hybrid approach with boundary value testing. (We can “reuse” the effort made in defining the equivalence classes) (e. g. Next. Date function) Equivalence class testing is indicated when the program function is complex. In such cases, the complexity of the function can help identify useful equivalence classes, as in the Next. Date function Strong equivalence class testing makes a presumption that the variables are independent when the Cartesian Product is taken. If there any dependencies, these will often generate “error” test cases, as they did in the Next. Date function 35 University of Waterloo
Guidelines and Observations 1. Several tries may be needed before “the right” equivalence relation is discovered, as we saw in the Next. Date example. In other cases, there is an “obvious” or “natural” equivalence partition. When in doubt, the best bet is to try to second guess aspects of any reasonable implementation 36 University of Waterloo
- Slides: 36