equivalence class testing use the mathematical concept of partitioning into equivalence classes to...

31
Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing The key goals for equivalence class testing are similar to partitioning: 1. completeness of test coverage 2. lessen duplication of test coverage

Upload: edith-hallford

Post on 15-Dec-2015

230 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Equivalence Class Testing

• Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

• The key goals for equivalence class testing are similar to partitioning:

1. completeness of test coverage2. lessen duplication of test coverage

Page 2: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Equivalence Class Test Cases

• Consider a numerical input variable, i, whose values may range from -200 through +200. Then a possible partitioning of testing input variable by 4 people may be:– -200 to -100– -101 to 0– 1 to 100– 101 to 200

• Define “same sign” as the equivalence relation, R, defined over the input variable’s value set, i = {-200 - -,0, - -, +200}. Then one partitioning will be:– -200 to -1 (negative sign)– 0 (no sign)– 1 to 200 (positive sign)

Page 3: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Weak Normal Equivalence testing

1. Assumes the ‘single fault’ or “independence of input variables.”

– e.g. If there are 2 input variables, these input variables are independent of each other.

2. Partition the test cases of each input variable separately into different equivalent classes.

3. Choose the test case from each of the equivalence classes for each input variable independently of the other input variable

Page 4: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Example of : Weak Normal Equivalence testing

Assume the equivalence partitioning of input X is: 1 to 10; 11 to 20, 21 to 30and the equivalence partitioning of input Y is: 1 to 5; 6 to 10; 11;15; and 16 to 20

X

Y1

10

20

30

1 5 10 15 20

We have covered everyoneof the 3 equivalence classesfor input X.

We have covered each of the 4 equivalence classes for input Y.

General rule for # of test cases?What do you think? # of partitions of the largest set?

For ( x, y )we have:(24, 2)(15, 8 )( 4, 13)(23, 17)

Page 5: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Strong Normal Equivalence testing

• This is the same as the weak normal equivalence testing except for

“multiple fault assumption”

or

“dependence among the inputs”

• All the combinations of equivalence classes of the variables must be included.

Page 6: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Example of : Strong Normal Equivalence testing

Assume the equivalence partitioning of input X is: 1 to 10; 11 to 20, 21 to 30and the equivalence partitioning of input Y is: 1 to 5; 6 to 10; 11;15; and 16 to 20

X

Y1

10

20

30

1 5 10 15 20

We have covered everyoneof the 3 x 4 Cartesian product of equivalenceclasses

General rule for # of test cases?What do you think?

Page 7: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Weak Robust Equivalence testing

• Up to now we have only considered partitioning the valid input space.

• “Weak robust” is similar to “weak normal” equivalence test except that the invalid input variables are now considered.

A note about considering invalid input is that there may not be any definition “specified” for the various, different invalid inputs - - - making definition of the output for these invalidinputs a bit difficult at times. (but fertile ground for testing)

Page 8: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Example of : Weak Robust Equivalence testing

Assume the equivalence partitioning of input X is 1 to 10; 11 to 20, 21 to 30and the equivalence partitioning of input Y is 1 to 5; 6 to 10; 11;15; and 16 to 20

X

Y1

10

20

30

1 5 10 15 20

We have covered everyone of the 5 equivalence classes for input X.

We have covered each of the 6 equivalence classes for input Y.

Page 9: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Strong Robust Equivalence testing

• Does not assume “single fault” - - - assumes dependency of input variables

• “Strong robust” is similar to “strong normal” equivalence test except that the invalid input variables are now considered.

Page 10: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Example of : Strong Robust Equivalence testing

Assume the equivalence partitioning of input X is: 1 to 10; 11 to 20, 21 to 30and the equivalence partitioning of input Y is: 1 to 5; 6 to 10; 11;15; and 16 to 20

X

Y1

10

20

30

1 5 10 15 20

We have covered everyoneof the 5 x 6 Cartesian product of equivalenceclasses (including invalidinputs)

Page 11: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Equivalence class Definition

• Note that the examples so far focused on defining input variables without considering the output variables.

• For the earlier “triangle problem,” we are interested in 4 questions:– Is it a triangle?– Is it an isosceles?– Is it a scalene?– Is it an equilateral?

• We may define the input test data by defining the equivalence class through “viewing” the 4 output groups:– input sides <a, b, c> do not form a triangle– input sides <a, b ,c> form an isosceles triangle– input sides <a, b, c> form a scalene triangle– input sides <a, b, c> form an equilateral triangle

Page 12: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Consider: Weak Normal Equivalence Test Cases for Triangle Problem

“valid” inputs: 1<= a <= 200 1<= b <= 200 1<= c <= 200 andfor triangle: a < b + c b < a + c c < b + a

output

Not triangle

Equilateral

Isosceles

Scalene

inputs

a b c

35 10 4

35 35 35

24 24 7

35 18 24NotTriangle

Equilateral

Scalene

Isosceles

Valid Inputs to get

Page 13: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Strong Normal Equivalence Test Cases for Triangle Problem

• Since there is no further sub-intervals inside the valid inputs for the 3 sides a, b, and c, are Strong Normal Equivalence is the same as the Weak Normal Equivalence

Page 14: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Weak Robust Equivalence Test Cases for Triangle Problem

NotTriangle

Equilateral

Scalene

Isosceles

Valid Inputs

Now, on top of the earlier 4 normal test cases, include the “invalid” inputs

<200,200,200>

<1, 1, 1>

Include 6 invalid test case in addition to Weak Normalabove: below: <201, 45, 50 > < -5, 76, 89 > <45, 204, 78 > < 56, -20, 89 > <50, 78, 208 > < 56, 89, 0 >

Page 15: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Strong Robust Equivalence Test Cases for Triangle Problem

• Similar to Weak robust, but all combinations of “invalid” inputs must be included to the Strong Normal.

• Look at the “cube” figure and consider the corners (two diagonal ones)

a) Consider one of the corners <200,200,200> : there should be (23 – 1) = 7 cases of “invalids” < 201, 201, 201 > < 50 , 201, 50 >< 201, 201, 50 > < 50 , 201, 201 >< 201, 50 , 201 > < 50, 50 , 201 >< 201, 50 , 50 >

b) There will be 7 more “invalids” when we consider the other corner , <1,1,1 >:

< 0, 0, 0 > <7, 0, 9 > < 0, 0, 5 > <8, 0, 0 > < 0, 10, 0 > <8, 9, 0 > < 0, 8, 10>

Page 16: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Next Day Program example

• Here we have 3 input variables and may choose to have the sets defined as (without partitioning of days, month, or year):

– Day : 1 through 31 days– Month: 1 through 12– Year: 0001 through 3000

• In this case, for weak normal equivalence testing only needs 1 test case from each input: – (year; month; day) : (2001, 9, 23)

• Clearly, this “non-partitioning” of the input gives very limited test case!

Page 17: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Next Day Program example (cont.)

• A more useful situation is to partition the 3 inputs. As an example:

– Day: 1 through 28– Day :29– Day: 30– Day: 31

– Month: those that have 31 days or {1,3,5,7,8,10,12}– Month: those that have 30 days or {4,6,9,11}– Month: that has less than 30 days or {2}

– Year: leap years between 0001 and 3000– Year: non-leap years between 0001 and 3000

4 partitions of days

3 partitions of months

2 partitions of years

Page 18: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Next Day Problem example (cont.)

• Weak Normal equivalence Test Cases:• Number of test cases is driven by the # of

partitions of the largest set, which in this case is the Days – has 4 partitions:

(year, month, day):

– (leap year, 10, 8) – (leap year, 4, 30)– (non-leap year, 2, 31)– (non-leap year, 7, 29)

How good is this set of test cases ?? How valuable is the “generic” Weak Normal test Cases? --- Not Much!

Without considering anyrelationship among the inputsand just mechanically following the rule

Page 19: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Next Day Problem example (cont.)

• What about the Strong Normal case where we consider all the permutations of the previously partitioned 3 inputs?– We should have (2 years x 3 months x 4 days) = 24 test cases

(leap year, 10, 5) (non-leap year, 10, 5)(leap year, 10, 30) (non-leap year, 10, 30)(leap year, 10, 31) (non-leap year, 10, 31)(leap year, 10, 29) (non-leap year, 10, 29)

(leap year, 6, 5) (non-leap year, 6, 5)(leap year, 6, 30) (non-leap year, 6, 30) (leap year, 6, 31) (non-leap year, 6, 31)(leap year, 6,29) (non-leap year, 6, 29)

(leap year, 2, 5) (non-leap year, 2, 5)(leap year, 2, 30) (non-leap year, 2, 30)(leap year, 2, 31) (non-leap year, 2, 31)(leap year, 2, 29) (non-leap year, 2, 29)

A little betterthan previous?

Page 20: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Next Day Problem example (cont.)

• What if we consider the invalids, Weak Robust?– 31 < days < 1– 12 < months < 1– 3000 < year < 0001

Then we need to include the following to the Weak Normal :

( valid year, 5, 45) ( valid year, 5, -5)

( valid year, 22, 30) ( 3500, 22, 45) ( valid year, 0, 15) ( 0000, 0 , -5)

( 3500, 7, 20 ) ( 0000, 7, 15) Would you combine or leave them separately?

Why?

Page 21: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Next Day Problem example (cont.)

• For Strong Robust, we need to consider and include all the permutations of the invalids to the Strong Normal:

• 3 inputs, so there are 23 – 1=7 invalids each for high and low, making a total of 14 more.

– ( 3025, 45, 80) ( 0000, -2, 0)– ( 3025, 45, 25) ( 0000, -2, 15)– ( 3025, 7, 80) ( 0000, 4 , 0)– ( 3025, 7, 25) ( 0000, 4, 10)– ( 2000, 45, 80) ( 2000, -2, 0)– ( 2000, 45, 25) ( 2000, -2, 10)– ( 2000, 7, 80) ( 2000, 4, 0)

Page 22: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

The Phone Company Example

• A phone company system has a function that computes the bill (or charge) of a call depending on:

• Call duration in minutes (Real number)• Destination country (integer code between 1 and 999)

(e.g. USA: 1, Jordan: 962, etc.)• The phone company of the receiver (integer code

between 1 and 200) (e.g. Zain:1, Orange: 2, etc.)• The call time

– If the call starts any time between midnight and 10:00 then call charge is 0.03 JD for each minute or fraction of minute.

– If the call starts any time between 10.01 and 17:00 then call charge is 0.04 JD for each minute or fraction of minute.

– If the call starts any time between 17.01 and 23.59 then call charge is 0.05 JD for each minute or fraction of minute.

Page 23: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Cont.

– If destination country code < 500 then add 1.00 JD to the call charge else add 0.50 JD to the call charge.

– If the receiving company code = 1 or 2 or 3 then add only 0.30 JD to the call charge else add 2.00 JD.

– Call duration of seconds are rounded up to the next larger minute.

– No call lasts more than 3 hours.

Page 24: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Cont.

Apply the following Equivalence Class based testing techniques for this billing function:

• Weak normal equivalence class testing

• Strong normal equivalence class testing

• Weak robust equivalence class testing

• Strong robust equivalence class testing

Page 25: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Valid relations

• R1 = { Call Duration : 0.1 =< cd <= 180.0 }• R2 = { Destination Country : 1 =< dest <= 499}• R3 = { Destination Country : 500 =< dest <=

999 }• R4 = { Phone Company : 0.1 =< comp <=

180.0 }• R5 = { Call Time : 0.0 =< ct <= 10.00 }• R6 = { Call Time : 10.01 =< ct <= 17.00 }• R7 = { Call Time : 17.01 =< ct <= 23.59 }

Page 26: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

Invalid relations

• R8 = { Call Duration : cd < 0.1 }• R9 = { Call Duration : cd > 180.0 }• R10 = { Destination Country : dest < 1 }• R11 = { Destination Country : dest > 999 }• R12 = { Phone Company : comp < 1 }• R13 = { Phone Company : comp > 200 }• R14 = { Call Time : ct < 0.0 }• R15= { Call Time : ct > 23.59 }

Page 27: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

1) Weak Normal EC Testing

Case ID cd dest comp ct Expected Output

WN1 90.0 250 2 5.00 90.0 * 0.03 + 1.00 + 0.30

WN2 90.0 750 102 13.30 90.0 * 0.04 + 0.50 + 2.00

WN3 90.0 750 102 20.30 90.0 * 0.05 + 0.50 + 2.00

Page 28: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

2) Strong Normal EC Testing

Case ID cd dest comp ct Expected Output SN1 90.0 250 2 5.00 90.0 * 0.03 + 1.00 + 0.30 SN2 90.0 250 2 13.30 … SN3 90.0 250 2 20.30 … SN4 90.0 250 102 5.00 … SN5 90.0 250 102 13.30 … SN6 90.0 250 102 20.30 … SN7 90.0 750 2 5.00 … SN8 90.0 750 2 13.30 … SN9 90.0 750 2 20.30 … SN10 90.0 750 102 5.00 … SN11 90.0 750 102 13.30 … SN12 90.0 750 102 20.30 …

Page 29: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

3) Weak Robust EC Testing

Case ID cd dest comp ct Expected Output WR1 -1 500 100 12.00 Call duration is out of range WR2 90.0 -1 100 12.00 Destination is out of range WR3 90.0 500 -1 12.00 Company is out of range WR4 90.0 500 100 -1 Call time is out of range WR5 180.01 500 100 12.00 Call duration is out of range WR6 90.0 1000 100 12.00 Destination is out of range WR7 90.0 500 201 12.00 Company is out of range WR8 90.0 500 100 24.01 Call time is out of range

Page 30: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing

4) Strong Robust EC Testing

SR1 .. SR8 is the same as WR1 .. WR6

Case ID cd dest comp ct Expected Output SR9 -1 -1 100 12.00 Call duration and destination

is out of range SR10 -1 500 -1 12.00 Call duration and company is

out of range SR11 -1 500 100 -1 … SR12 90.0 -1 -1 12.00 … SR13 90.0 -1 100 -1 … SR14 90.0 500 -1 -1 … SR15 -1 -1 -1 12.00 … SR16 … … … … …

Page 31: Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing