Software Testing Instructor KaiYu Wan

1

Overview ÎFunctional Testing ÎBoundary Value Testing (BVT) ÎBoundary Value Analysis ÎRobustness Testingg ÎWorst Case Testing ÎSpecial Value Testing

ÎEquivalence Class Testing ÎWeak Normal Equivalence Class Testing ÎStrong Normal Equivalence Class Testing ÎWeak Robust Equivalence Class Testing ÎStrong Robust Equivalence Class Testing

ÎDecision Table Based testing

2

Equivalence Class Testing • BVT assumes that input variables are independent of one another • BVT tends to generate more test cases with poorer test coverage g ((with the independence p assumption) p ) than domain or equivalence testing. • Equivalence classes form a partition of a set that is a collection ll i off mutually ll disjoint di j i subsets b whose h union i is i the entire set. • Two important implications for testing: – The fact that the entire set is represented provides a form of completeness – The disjointness assures a form of non-redundancy3

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. • Th The key k point i in i equivalence i l class l testing i is i the h choice of the equivalence relation that determines the classes (partitions) (partitions). 4

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 specification ifi ti provides id – must understand how inputs are mutually d dependent. d t

5

Equivalence Class Testing for 2 2-variable i bl function f ti • Consider a function f(x1,x2) f(x1 x2) where the values of x1 and x2 are defined to be a 31} Y2= {year | year < 1812} Y3= {year | year > 2012} 33

Weak Normal & Strong Normal Test Cases • Because the number of valid classes equals the number b off iindependent d d variables, i bl only l one weakk normal equivalence class test case occurs, and it is id i l to the identical h strong normall equivalence i l class l test case : Case ID WN1,, SN1

Month

Day

Year

Expected Output

6

15

1912

6/16/1912

Weak Robust Test Cases • Here is the full set of weak robust test cases: Case ID

Month

Day

Year

WR1 WR2 WR3 WR4 WR5 WR6 WR7

6 -11 13 6 6 6 6

15 15 15 -11 32 15 15

1912 1912 1912 1912 1912 1811 2013

Expected Output p 6/16/1912 Invalid Invalid Invalid Invalid I lid Invalid Invalid 35

Strong Robust Test Cases • Here is one “corner” of the cube in 3-space of the additional ddi i l strong robust b test cases: Case ID

Month

Day

Year

Expected Output

SR1

-1

15

1912

Invalid

SR2

6

-1

1811

Invalid

SR3

6

13

1811

Invalid

SR4

-1

-1

1912

Invalid

SR5

6

-1

1811

Invalid

SR6

-1

15

1811

Invalid

SR7

-1

-1

1811

Invalid

36

Choice of Equivalence Classes • If we more carefully chose the equivalence relation, the resulting equivalence classes will be more useful • What must be done to an input date? – If it is not the last day of a month, day=day+1; – Else if it is not the last month of a year year, day=1 day 1, month=month+1; – Else day=1,month=1, y , , and yyear=year+1 y – The problem of leap year 37

Choice of Equivalence Classes • E Equivalence i l classes: l M1= {month | month has 30 days} M2 {month M2= { th | month th has h 31 days} d } M3= {month | month is February} D1 {day D1= {d | 1 ≤ dday ≤ 28} D2= {day | day = 29} D3 {day D3= {d | day d = 30} D4= {day | day=31} Y1 {year Y1= { | year = 2000} Y2= {year | year is a leap year} Y3 {year Y3= { | year iis a common year}} 38

Why choosing these classes? • Separate classes for 30- and 31-day months - the last day of the month; • February – leap year; • Days in D1 always incremented; • Days in D4 only have meaning for months in M2; • Three classes for years

Weak Equivalence Class Test Cases • The inputs are mechanically selected from the approximate middle of the corresponding class: Case ID

Month

Day

Year

Expected Output

WN1

6

14

2000

6/15/2000

WN2

7

29

1912

7/30/1912

WN3

2

30

2002

2/31/2002(Impossible dates)

WN4

6

31

2000

7/1/2000(Impossible input date)

• Mechanical selection doesn doesn’tt consider domain knowledge, thus the two impossible dates. This will always be a problem with “automatic” automatic test case generation.

40

Strong Normal Equivalence Test Cases CASE ID

Month

Day

Year

Output

SR1

6

14

2000

6/15/2000

SR2

6

14

1996

6/15/1996

SR3

6

14

2002

6/15/2002

SR4

6

29

2000

6/30/2000

SR5

6

29

1996

6/30/1996

SR6

6

29

2002

6/30/2002

SR7

6

30

2000

6/31/2000(imposs ible date)

SR8

6

30

1996

6/31/1996(imposs ible date)

SR9

6

30

2002

6/31/2002(imposs 41 ible date)

Strong Normal Equivalence Test Cases CASE ID

Month

Day

Year

Output

SR10

6

31

2000

7/1/2000( invalid input)

SR11

6

31

1996

7/1/1996( invalid input)

SR12

6

31

2002

7/1/2002( invalid input)

SR13

7

14

2000

7/15/2000

SR14

7

14

1996

7/15/1996

SR15

7

14

2002

7/15/2002

SR16

7

29

2000

7/30/2000

SR17

7

29

1996

7/30/1996

SR18

7

29

2002

7/30/2002 42

Strong Normal Equivalence Test Classes CASE ID

Month

Day

Year

Output

SR19

7

30

2000

7/31/2000

SR20

7

30

1996

7/31/1996

SR21

7

30

2002

7/31/2002

SR22

7

31

2000

8/1/2000

SR23

7

31

1996

8/1/1996

SR24

7

31

2002

8/1/2002

SR25

2

14

2000

2/15/2000

SR26

2

14

1996

2/15/1996

SR27

2

14

2002

2/15/2002 43

Strong Normal Equivalence Test Classes CASE ID

Month

Day

Year

Output

SR28

2

29

2000

3/1/2000(invalid input)

SR29

2

29

1996

3/1/1996

SR30

2

29

2002

3/1/2002(impossible date)

SR31

2

30

2000

3/1/2000(impossible date)

SR32

2

30

1996

3/1/1996(impossible date)

SR33

2

30

2002

3/1/2002 (impossible date)

SR34

2

31

2000

7/1/2000(impossible date)

SR35

2

31

1996

7/1/1996(impossible date)

SR36

2

31

2002

7/1/2002(impossible date) 44

Some reflection • Moving from weak to strong normal testing raises redundancy. d d Always Al makes k the h presumption i off independence, and this is reflected in the crossproduct d off the h equivalence i l classes. l – 3(month) * 4 (day) *3 (year)=36; – if add two invalid classes for each variable : 150 • If we merge Y1 and Y3, and call the result the set of common years years, test cases are reduced to 24

Equivalence Class Test Cases for the Commission Problem • The valid classes for the input variables are : L1={ locks : 1