forms of equivalence class testing

14
Paul C. Jorgensen Software Testing: A Craftsman's Approach Equivalence Class Testing 1 2 3 4 5 6 1 2 3 4 1 2 3 4 5 A B C Equivalence Class Testing Domain Range F Equivalence class testing uses information about t functional mapping itself to identify test cases

Upload: jolene-rasmussen

Post on 30-Dec-2015

37 views

Category:

Documents


2 download

DESCRIPTION

Forms of Equivalence Class Testing. Normal. • only equivalence classes are valid and invalid input values. • emphasis is on "single failures". • works well when variables have a valid range. • test cases: check valid case, then check invalid combinations by using. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Equivalence Class Testing

Domain Range

F

Equivalence class testing uses information about the functional mapping itself to identify test cases

Page 2: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Equivalence Partitioning

Domain Range

F Define relation R as follows: for x, y in domain, xRy iff F(x ) = F(y). Facts: 1. R is an equivalence relation. 2. An equivalence relation induces a partition on a set. 3. Works best when F is many-to-one 4. (pre-image set)

DomainRange

Test cases are formed by selecting one value from each equivalence class. - reduces redundancy - identifying the classes may be hard

Page 3: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Forms of Equivalence Class Testing

Normal • only equivalence classes are valid and invalid input values • emphasis is on "single failures" • works well when variables have a valid range • test cases: check valid case, then check invalid combinations by using one invalid value with remaining valid values. Weak • more complex equivalence classes of valid input values • variables may have several ranges of valid values • test cases "cover" valid combinations Strong • equivalence classes as in weak form • cross product of equivalence classes of valid input values • presumes variables are independent We compare these for a function of three variables, F(x1, x2, x3)

Page 4: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Forms of Equivalence Class Testing

• Normal: classes of valid values of inputs

• Robust: classes of valid and invalid values of inputs

• Weak: (single fault assumption) one from each class

• Strong: (multiple fault assumption) one from each class in Cartesian Product

• We compare these for a function of three variables, F(x1, x2, x3)

Page 5: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Traditional Equivalence Class Testing

Variable Valid input set Invalid input sets x1 a V1X1 v NV1X1, w NV2X1 x2 b V1X2 x NV1X2 x3 c V1X3 y NV1X3, z NV2X3 Test cases normal F(a, b, c) x3 invalid F(a, b, v), F(a, b, w), F(a, b, x), F(a, b, y), F(a, b, z) x2 invalid F(a, v, c), F(a, w, c), F(a, x, c), F(a, y, c), F(a, z, c) x1 invalid F(v, b, c), F(w, b, c), F(x, b, c), F(y, b, c), F(z, b, c)

Page 6: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Equivalence Classes: Valid(x1) : a Š x1 Š b; Invalid(x1) : x1 Š a , x1 b Valid(x2) : c Š x2 Š d; Invalid(x2) : x2 Š c , x2 d

a b

c

d

x2

x1

Weak Robust Equivalence Class Test Cases

Page 7: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Weak Robust Equivalence Class Testing

Variable Valid input set x1 a1 V1X1, a2 V2X1 x2 b1 V1X2, b2 V2X2, b3 V3X2, b4 V4X2 x3 c1 V1X3, c2 V2X3, c3 V3X3 Test cases F(a1, b1, c1) F(a2, b2, c2) F(a1, b3, c3) F(a2, b4, c1)

Page 8: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Equivalence Classes: x1 : a Š x1 Š b, b < x1 Š c, c < x1 Š d x2 : e Š x2 Š f, f < x2 Š g

a b c d

x2

x1

Weak Normal Equivalence Class Test Cases

e

f

g

Page 9: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Strong Normal Equivalence Class Testing

Variable Valid input set x1 a1 V1X1, a2 V2X1 x2 b1 V1X2, b2 V2X2, b3 V3X2, b4 V4X2 x3 c1 V1X3, c2 V2X3, c3 V3X3 Test cases F(a1, b1, c1), F(a1, b1, c2), F(a1, b1, c3) F(a1, b2, c1), F(a1, b2, c2), F(a1, b2, c3) F(a1, b3, c1), F(a1, b3, c2), F(a1, b3, c3) F(a1, b4, c1), F(a1, b4, c2), F(a1, b4, c3) F(a2, b1, c1), F(a2, b1, c2), F(a2, b1, c3) F(a2, b2, c1), F(a2, b2, c2), F(a2, b2, c3) F(a2, b3, c1), F(a2, b3, c2), F(a2, b3, c3) F(a2, b4, c1), F(a2, b4, c2), F(a2, b4, c3

Page 10: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Equivalence Classes: x1 : a Š x1 Š b, b < x1 Š c, c < x1 Š d x2 : e Š x2 Š f, f < x2 Š g

a b c d

x2

x1

Strong Normal Equivalence Class Test Cases

e

f

g

Page 11: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Selecting an Equivalence Relation

There is no such thing as THE equivalence relation. If x and y are days, some possibilities for Nextdate are: 1. x R y iff x and y are mapped onto the same year 2. x R y iff x and y are mapped onto the same month 3. x R y iff x and y are mapped onto the same date 4. x R y iff x(day) and y(day) are "treated the same" 5. x R y iff x(month) and y(month) are "treated the same" 6. x R y iff x(year) and y(year) are "treated the same" Best practice is to select an equivalence relation that reflects the behavior being tested.

Page 12: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

NEXTDATE Equivalence Classes

Month: M1 = { month : month has 30 days} M2 = { month : month has 31 days} M3 = { month : month is February} Day: D1 = {day : 1 Š day Š 28} D2 = {day : day = 29 } D3 = {day : day = 30 } D4 = {day : day = 31 } Year: Y1 = {year : year = 2000} Y2 = {year : 1812 Š year Š 2012 AND (year ° 2000) AND (year = 0 mod 4)} Y3 = {year : (1812 Š year Š 2012 AND (year ° 0 mod 4)) AND (year ° 2000)}

Page 13: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Weak Equivalence Class Test Cases

Select test cases so that one element from each input domain equivalence class is used as a test input value.

April 1 1900 Jan. 29 1812 Feb. 30 1813 April 31 1900

EC-1 EC-2 EC-3 EC-4

Test Case

Input Domain Equiv. Classes

Input Values Expected Outputs

M1, D1, Y1 M2, D2, Y2 M3, D3, Y3 M1, D4, Y1

April 2 1900 Jan. 30 1812 impossible impossible

Notice that Weak Equivlaence testing presumes that the variables in the input domain are independent; logical dependencies are unrecognized.

Page 14: Forms of Equivalence Class Testing

Paul C. JorgensenSoftware Testing: A Craftsman's Approach Equivalence Class Testing

1

2

3 4

5

6

1

2

3

4

1

2 3

4

5

A B C

Revised Nextdate Domain Equivalence Classes

Month: M1 = { month : month has 30 days} M2 = { month : month has 31 days except Dec.} M3 = { month : month is February} M4 = { month : month is December} Day: D1 = {day : 1 Š day Š 27} D2 = {day : day = 28 } D3 = {day : day = 29 } D4 = {day : day = 30 } D5 = {day : day = 31 } Year: Y1 = {year : year is a leap year} Y2 = {year : year is not a leap year} The cross product of these contains 40 elements.