ECE 453 CS 447 SE 465 Software Testing

  • Slides: 26
Download presentation
ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor

ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis 1

Overview èFunctional Testing èBoundary Value Testing (BVT) èBoundary Value Analysis èRobustness Testing èWorst Case

Overview èFunctional Testing èBoundary Value Testing (BVT) èBoundary Value Analysis èRobustness Testing èWorst Case Testing èSpecial Value Testing èEquivalence Class Testing èWeak Equivalence Class Testing èStrong Equivalence Class Testing èTraditional Equivalence Class testing èDecision Table Based testing 2

Equivalence Class Testing • The use of equivalence class testing has two motivations: –

Equivalence Class Testing • The use of equivalence class testing has two motivations: – – • Sense of complete testing Avoid redundancy Two important implications for testing: 1. The fact that the entire set is represented provides a form of completeness 2. The disjointness assures a form of non-redundency 3

Equivalence Classes • The idea of equivalence class testing is to identify test cases

Equivalence Classes • The idea of equivalence class testing is to identify test cases by using one element from each equivalence class. • If the equivalence classes are chosen wisely this greatly reduces the potential redundancy among test cases. • The key point in equivalence class testing is the choice of the equivalence relation that determines the classes (partitions). • We will differentiate below, between weak and strong equivalence class testing. 4

Equivalence Class Selection • tends to much of a “craft”: – no dependence on

Equivalence Class Selection • tends to much of a “craft”: – no dependence on knowledge of code, only the specification – needs knowledge of input domain that usually goes beyond what an interface design spec provides » familiarity with specifications – must understand how inputs are mutually dependent. 5

Example • Let us consider a program P with 3 inputs: a, b and

Example • Let us consider a program P with 3 inputs: a, b and c and the corresponding input domains are A, B, and C. – let there be defined the partition: 6

 • define a 1, a 2 and a 3 as: – let ai

• define a 1, a 2 and a 3 as: – let ai be a “representative” or “typical” value within its respective equivalence class (e. g. the midpoint in a linear equivalence class). – similarly define bi and ci. • test cases can be stated for the inputs <a, b, c> in terms of the representative points. • the basic idea behind the techniques is that one point within an equivalence class is just as good as any other point within the same class. (? ) 7

Weak Equivalence Class Testing • Weak equivalence class testing is accomplished by using one

Weak Equivalence Class Testing • Weak equivalence class testing is accomplished by using one variable from each equivalence class in a test case. • The minimum number of test cases is equal to the number of classes in the partition with the largest number of subsets. • From the previous example, we have: Test Case Variable a Variable b Variable c WE 1 a 1 b 1 c 1 WE 2 WE 3 WE 4 a 2 a 3 a 1 b 2 b 3 B 4 c 2 c 1 c 2 8

Strong Equivalence Class Testing • Strong equivalence class testing is based on the Cartesian

Strong Equivalence Class Testing • Strong equivalence class testing is based on the Cartesian Product of the partition subsets. • From the previous example, this would generate: 3 * 4 * 2 = 24 test cases • Generates more test cases which test for any interaction between the representative values from each of the subsets. • For either method, it may be possible to define equivalence relations for the program output, then test cases can also be 9 based on these.

Test Case # a b c SE 1 a 1 b 1 c 1

Test Case # a b c SE 1 a 1 b 1 c 1 SE 2 a 1 b 1 c 2 SE 3 a 1 b 2 c 1 SE 4 a 1 b 2 C 2 SE 5 a 1 b 3 C 1 SE 6 a 1 b 3 C 2 SE 7 a 1 b 4 C 1 SE 8 a 1 b 4 C 2 SE 9 a 2 b 1 C 1 SE 10 a 2 b 1 C 2 SE 11 a 2 b 2 C 1 SE 12 a 2 b 2 C 2 SE 13 a 2 b 3 C 1 SE 14 a 2 b 3 C 2 SE 15 a 2 b 4 C 1 SE 16 a 2 b 4 C 2 SE 17 a 3 b 1 C 1 SE 18 a 3 b 1 C 2 SE 19 a 3 b 2 C 1 SE 20 a 3 b 2 C 2 SE 21 a 3 b 3 C 1 SE 22 a 3 b 3 C 2 SE 23 a 3 b 4 C 1 SE 24 a 3 b 4 c 2 10

Traditional View • The traditional view of equivalence class testing defines equivalence in terms

Traditional View • The traditional view of equivalence class testing defines equivalence in terms of validity that is, test cases determined from the valid and invalid values for each input variable. • For each input variable there are valid and invalid values. • In the traditional approach, these are identified and numbered, and then incorporated into test cases in the weak sense as presented above. 11

Traditional View • Given valid and invalid sets of inputs, the traditional equivalence testing

Traditional View • Given valid and invalid sets of inputs, the traditional equivalence testing strategy identifies test cases as follows: – For valid inputs, use one value from each valid class (as in what we have called weak equivalence class testing). In this context, each input in these test cases will be valid. – For invalid inputs, a test case will have one invalid value and the remaining values will be valid. In this context, a “single failure” should cause the test case to fail. • If the input variables have defined ranges, then the test cases from traditional equivalence class testing will always be a subset of those that would be generated by robustness testing. 12

Issues with Traditional View • There are two problems with the traditional equivalence testing:

Issues with Traditional View • There are two problems with the traditional equivalence testing: – The first is that, very often, the specification does not define what the expected value for an invalid test case should be. – The second problem is that strongly typed languages eliminate the need for the consideration of invalid inputs. 13

Example • For example consider a program with two input variables size and weight:

Example • For example consider a program with two input variables size and weight: – valid ranges: S 1: 0 < size < 200 W 1: 0 < weight < 1500 – corresponding invalid ranges might be: 14

Test Cases Example (Traditional View) Test Case TE 1 TE 2 size weight 100

Test Cases Example (Traditional View) Test Case TE 1 TE 2 size weight 100 750 -1 Expected Output what ever it should be invalid input TE 3 100 1500 invalid input TE 4 -1 750 invalid input TE 5 200 750 invalid input 15

Equivalence Test Cases for the Triangle Problem (Output Domain) • In the problem statement

Equivalence Test Cases for the Triangle Problem (Output Domain) • In the problem statement we note that there are four possible outputs: – – Not a Triangle Isosceles Equilateral Scalene • We can use these to identify output (range) equivalence classes: R 1= {<a, b, c> | the triangle with sides a, b, c, is equilateral} R 2= {<a, b, c> | the triangle with sides a, b, c, is isosceles} R 3= {< a, b, c> | the triangle with sides a, b, c, is scalene} R 4= {a, b, c> | sides a, b, c do not form a triangle} • These classes yield the following simple set of test cases: 16

Sample Test Cases based on Output Domain Test Case a b c Expected Output

Sample Test Cases based on Output Domain Test Case a b c Expected Output OE 1 5 5 5 Equilateral OE 2 2 2 3 Isosceles OE 3 3 4 5 Scalene OE 4 4 1 2 Not a Triangle 17

Equivalence Test Cases for the Triangle Problem (Input Domain) • If we base the

Equivalence Test Cases for the Triangle Problem (Input Domain) • If we base the equivalence classes on the input domain, we will obtain a larger set of test cases. We can define the sets: 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} • As a separate property we can apply the triangle property to see even if the input constitutes a triangle D 6= {<a, b, c> | a ≥ b+c} D 7= {<a, b, c> | b ≥ a+c} D 8= {<a, b, c> | c ≥ a+b} • If we wanted also we could split D 6 into D 6’={<a, b, c> | a = b+c} and D 6’’= {<a, b, c> | a > b+c} 18

Equivalence Test Cases for the Next. Date Problem (Input Domain) • Nextdate is a

Equivalence Test Cases for the Next. Date Problem (Input Domain) • Nextdate is a function of three variables, month, day, and year and these have ranges defined as: 1 ≤ month ≤ 12 1 ≤ day ≤ 31 1812 ≤ year ≤ 2012 • We will examine below the valid, invalid equivalence classes, strong, and weak equivalence class testing. 19

Traditional Test Cases • The valid equivalence classes are: M 1= {month | 1

Traditional Test Cases • The valid equivalence classes are: M 1= {month | 1 ≤ month ≤ 12} D 1= {day | 1 ≤ day ≤ 31} Y 1= {year | 1812 ≤ year ≤ 2012} The invalid equivalence classes are: 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} These classes yield the following test cases, where the valid inputs are mechanically selected from the approximate middle of the valid range: 20

Traditional Test Cases Case ID Month Day Year TE 1 6 15 1912 Expected

Traditional Test Cases Case ID Month Day Year TE 1 6 15 1912 Expected Output 6/16/1912 TE 2 -1 15 1912 Invalid TE 3 13 15 1912 Invalid TE 4 6 -1 1912 Invalid TE 5 6 32 1912 Invalid TE 6 6 15 1811 Invalid TE 7 6 15 2013 Invalid 21

Choice of Equivalence Classes • If we more carefully chose the equivalence relation, the

Choice of Equivalence Classes • If we more carefully chose the equivalence relation, the resulting equivalence classes will be more useful 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 = 0 mod 4} Y 3= {year | 1812 ≤ year ≤ 2021 AND year ≠ 0 mod 4} 22

Weak Equivalence Class Test Cases Case ID Month Day Year Expected Output WE 1

Weak Equivalence Class Test Cases Case ID Month Day Year Expected Output WE 1 6 14 1900 6/15/1900 WE 2 7 29 1912 7/30/1912 WE 3 2 30 1913 Invalid WE 4 6 31 1900 Invalid 23

Strong Equivalence Test Cases CASE ID Month Day Year Output SE 1 6 14

Strong Equivalence Test Cases CASE ID Month Day Year Output SE 1 6 14 1900 6/15/1900 SE 2 6 14 1912 6/15/1912 SE 3 6 14 1913 6/15/1913 SE 4 6 29 1900 6/30/1900 SE 5 6 29 1912 6/30/1912 SE 6 6 29 1913 6/30/1913 SE 7 6 30 1900 7/1/1900 SE 8 6 30 1912 7/1/1912 SE 9 6 30 1913 7/1/1913 SE 10 6 31 1900 ERROR SE 11 6 31 1912 ERROR SE 12 6 31 1913 ERROR SE 13 7 14 1900 7/15/1900 SE 14 7 14 1912 7/15/1912 SE 15 7 14 1913 7/15/1913 SE 16 7 29 1900 7/30/1900 SE 17 7 29 1912 7/30/1912 SE 18 7 29 1913 7/30/1913 24

Strong Equivalence Test Classes CASE ID Month Day Year Output SE 19 7 30

Strong Equivalence Test Classes CASE ID Month Day Year Output SE 19 7 30 1900 7/31/1900 SE 20 7 30 1912 7/31/1912 SE 21 7 30 1913 7/31/1913 SE 22 7 31 1900 8/1/1900 SE 23 7 31 1912 8/1/1912 SE 24 7 31 1913 8/1/1913 SE 25 2 14 1900 2/15/1900 SE 26 2 14 1912 2/15/1912 SE 27 2 14 1913 2/15/1913 SE 28 2 29 1900 ERROR SE 29 2 29 1912 3/1/1912 SE 30 2 29 1913 ERROR SE 31 2 30 1900 ERROR SE 132 2 30 1912 ERROR SE 33 2 30 1913 ERROR SE 34 2 31 1900 ERROR SE 35 2 31 1912 ERROR SE 36 2 31 1913 ERROR 25

Guidelines and Considerations • The traditional form of equivalence testing is generally not as

Guidelines and Considerations • The traditional form of equivalence testing is generally not as thorough as weak equivalence testing, and in its turn, not as thorough as strong equivalence testing • If error conditions is a priority we can extend strong equivalence testing to include invalid classes • Equivalence class testing is appropriate when input data is defined in terms of ranges and sets of discrete values. • Logic of functionality of the program can help define the equivalence classes • Strong equivalence takes the presumption that variables are independent, otherwise it generates some “error” test cases • Can be strengthened by using it with domain testing (boundary value) – reuse the work to define the ranges. – Does not consider elements at equivalence class boundaries – need to expand ECT to include BVT-like requirements (domain testing) 26