27
Chapter 2: Boundary Value Testing : BVT 322235 Software Testing By Dr. Wararat Songpan (Rungworawut) Faculty of Computer Science, Department of Science, Khon Kaen University, Thailand

Chapter 2: Boundary Value Testing : BVT 322235 Software Testing

  • Upload
    umeko

  • View
    40

  • Download
    1

Embed Size (px)

DESCRIPTION

Chapter 2: Boundary Value Testing : BVT 322235 Software Testing. By Dr. Wararat Songpan ( Rungworawut ) Faculty of Computer Science, Department of Science, Khon Kaen University, Thailand. Guideline of B oundary V alue T esting. This technique focuses on variable as number. - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Chapter 2: Boundary Value Testing : BVT

322235 Software Testing

ByDr. Wararat Songpan (Rungworawut)

Faculty of Computer Science, Department of Science,

Khon Kaen University, Thailand

Page 2: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Guideline of Boundary Value

Testing

• This technique focuses on variable as number.

Page 3: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Boundary Value Testing : BVT• BVT is a black box testing technique• There are 4 sub-techniques of BVT

1) Boundary Value Analysis: BVA 2) Robustness Testing: RT 3) Worst-Case Testing: WT 4) Robust Worst-Case Testing: RWT

Page 4: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

1) Boundary Value Analysis: BVA

• When the function F is implemented as a program, the input variable x1 and x2 will have boundaries as follows,

• a =< x1 =< b• c =< x2 =< d

x2

x1

d

c

a b

Page 5: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Example: A function of addition

x1

x2

Function: Addition X1 and x2

Results =

Spec.1<=x1<

=10

Spec.1<=x2<

=10

Page 6: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

1) Boundary Value Analysis:

BVA(Cont.)

• The 5 values used to test the extremities are:

1) minimum (min) 2) above minimum (min+) 3) nominal (nom) 4) below maximum (max-) 5) maximum (max)

Page 7: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

1) Boundary Value Analysis:

BVA(Cont.) BVA Test cases for

function FX1 X2 Expect

ed Results

x1nom x2min

x1nom x2min+

x1nom x2nom

x1nom x2max-

x1nom x2max

x1min x2nom

x1min+ x2nom

x1nom x2nom

x1max- x2nom

x1max x2nom

The number of test case is 4n+1

,where n is the number of variable

Page 8: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

1) Boundary Value Analysis:

BVA(Cont.) BVA Test cases for

function F of additionX1 X2 Expect

ed Results

5 1 6

5 2 7

5 5 10

5 9 14

5 10 15

? ? ?

x1

x2

Function: Addition X1 and x2

Results =

Page 9: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

• The idea and motivation behind BVA is that errors tend to occur near the extremities of the input variables. The defects found on the boundaries of these input variables can obviously be the result of countless possibilities.

• For example if the programmer forgot to count from zero or they just miscalculated. Errors in the code concerning loop counters being off by one or the use of a < operator instead of ≤.

• One of the values taking on their extreme values at any one particular time. The reason for this is that generally Boundary Value Analysis uses that called “Single Fault Assumption”.

1) Boundary Value Analysis:

BVA(Cont.)

Page 10: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Example: The Triangle Problem

• Problem statements (Simple version)

• input 3 integers: a, b, c are side of triangle

• Output is type of triangleo Equilateralo Isosceles o Scaleneo Not a Triangle (how to chek it?)

Page 11: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Example: The Triangle Problem

• Problem statements (Improved version)o input 3 integers: a, b, c are side of triangle

• Spec and conditiono c1: 1 =< a =<200 c4: b+c > a (As a

triangle)o c2: 1 =< b =<200 c5: a+c > b (As a

triangle)o c3: I =< c =< 200 c6: a+b > c (As a

triangle)

• Output is type of triangleo Equilateralo Isosceleso Scaleneo Not a Triangle

Page 12: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

The Triangle Problem: FlowchartInput a, b, c

Match=0

a=b?

a=c?

b=c?

Match=Match+1

Match=Match+2

Match=Match+3

Match=0?

Match=1?

Match=2?

a+b ≤ c?

b+c ≤ a?

Match=3?

a+c ≤ b?

a+b ≤ c?

a+c ≤ b?

b+c ≤ a?

y

y

y

y

y

y

yy

y

y

y

y

y

n

n

n

n

n

n

n

n

n

n

n

n

n

EquilateralIsosceles

Not a Triangle Scalene

Page 13: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Triangle: BVA Test Cases DesignTest case

IDa b c Expected Results Actual Results

1 100 100 1 Isosceles

2 100 100 2 Isosceles

3 100 100 100 Equilateral

4 100 100 199 Isosceles

5 100 100 200 Not a Triangle

6 100 1 100 Isosceles

7 100 2 100 Isosceles

8 100 100 100 Equilateral

9 100 199 100 Isosceles

10 100 200 100 Not a Triangle

11 1 100 100 Isosceles

12 2 100 100 Isosceles

13 100 100 100 Equilateral

14 199 100 100 Isosceles

15 200 100 100 Not a Triangle

Page 14: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Example: The Next Date Function

• Problem Statementso input 3 variables: month, date, year

• Output: o as the next date from input the date

• Spec. and Conditions:o C1: January =< month =< Decembero C2: 1 =< day =< 31o C3: 1812 =< year =< 2012

**Remark: The year should be verified as leap year

Page 15: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Leap Year• One year has the length of 365 days, 5 hours, 48

minutes and 47 seconds. • A normal year has been given 365 days and a leap

year 366 days. • So at leap years February 29th is added, which

doesn't exist in a normal year. • A leap year is every 4 years, but not every 100

years, then again every 400 years.• For example:

o 1992 is Leap Year (1992 mod 4 = 0 but1992 mod 100 and 400 ≠ 0) o 1900 is NOT a Leap Year (1900 mod 4 and 1900 mod100 = 0 but 1900

mod 400 ≠ 0)o 2000 is Leap Year (2000 mod 4,100 and 400 = 0)

Page 16: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Next Date: BVA Test Cases DesignTest case

IDMonth Day Year Expected Results Actual Results

1 June 15 1812 June 16, 1812

2 June 15 1813 June 16, 1813

3 June 15 1912 June 16, 1912

4 June 15 2011 June 16, 2011

5 June 15 2012 June 16, 2012

6 June 1 1912

7 June 2 1912

8 June 15 1912

9 June 30 1912

10 June 31 1912

11 January 15 1912

12 February 15 1912

13 June 15 1912

14 November 15 1912

15 December 15 1912

Page 17: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

2) Robustness Testing: RT

• Robustness testing can be seen as and extension of Boundary Value Analysis.

• The idea behind Robustness testing is to test input variables that fall just outside this input domain.

• We use two more values for each variable min- and max+ which are designed to fall just outside of the input range.

• Robustness testing is still “Single Fault Assumption” because one of the values taking on their 7 extreme values at any one particular time.

Page 18: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Robustness Test cases for function F

The number of test case is 6n+1

,where n is the number of variable

2) Robustness Testing: RTX1 X2 Expected Results

x1nom x2min- Alert message (out of range)

x1nom x2min

x1nom x2min+

x1nom x2nom

x1nom x2max-

x1nom x2max

x1nom x2max+

x1min- x2nom

x1min x2nom

x1min+ x2nom

x1nom x2nom

x1max- x2nom

x1max x2nom

x1max+ x2nom

Page 19: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

• Worst-case Testing uses the critical fault assumption for more than one variable at a time assuming its extreme values called “multiple faults assumption”

• So we are able to test the outcome if more than one variable were to assume its extreme value.

• To generate test cases we take the original 5 extreme values (min, min+, nom, max-, max) and perform the Cartesian product of these values. The end product is a much larger set of results than we have seen before.

3) Worst-Case Testing: WT

Page 20: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

3) Worst-Case Testing: WT(Cont.)

The number of test case is 5n

,where n is the number of variable

Worst-Case Test cases for function F

x1 x2

minmin+nommax-max

minmin+nommax-max

Page 21: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

322 235 Software Testing

Worst-Case Test cases for function F

X1 X2 Expected Results

x1min x2min

x1min x2min+

x1min x2nom

x1min x2max-

x1min x2max

x1min+ x2min

x1min+ x2min+

x1min+ x2nom

x1min+ x2max-

x1min+ x2max

… …

… …

3) Worst-Case Testing: WT(Cont.)

Page 22: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

• If the function under test were to be of the greatest importance we could use a method named Robust Worst-Case testing which as the name suggests draws it attributes from Robust Worst-Case testing.

• Test cases are constructed by taking the Cartesian product of the 7 extreme values (min-, min, min+, nom, max-, max, max+)

• There are more than one variable at a time assuming its extreme values occurred critical fault called “multiple faults assumption”

4) Robust Worst-Case Test: RWT

Page 23: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

4) Robust Worst-Case Test: RWT

x1 x2

min-minmin+nommax-maxmax+

min-minmin+nommax-maxmax+

The number of test case is 7n

,where n is the number of variable

Page 24: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

322 235 Software Testing

4) Robust Worst-Case Test: RWT

Robust Worst-Case Test cases for function F

X1 X2 Expected Results

x1min- x2min-

x1min- x2min

x1min- x2min+

x1min- x2nom

x1min- x2max-

x1min- x2max

x1min- x2max+

x1min x2min-

x1min x2min

x1min x2min+

… …

… …

Page 25: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

How to use Boundary Value Testing(BVT)

• BVT is considered in 2 approaches:1) By the number of variables.

o We could use a certain set integer, we could allow the program to use the highest or lowest possible integer.

2) By the kind of ranges.o For example in the Next Date exampleo Some languages to declare an enumerated

type {Jan, Feb, Mar,......, Dec}. It would normally encode for testing of the month’s variable so that January corresponded to 1 and February corresponded to 2 etc.

Page 26: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Summary of Boundary Value Testing (BVT)

• BVT only focuses on variable as number.

• BVT works well for consideration the function of several independent variables that represent boundary value such as Triangle Program. But it is not good enough for the next date program that has dependent variable.

Page 27: Chapter  2:  Boundary  Value  Testing  :  BVT 322235 Software Testing

Summary of Boundary Value Testing (BVT)

• BVT has divided into 2 characteristics:

Normal (Valid) Robust (Valid+Invalid)

•Boundary Value Analysis•Worst-Case Testing

• Robustness Testing• Robust Worst-Case Testing

2) Single fault vs multiple fault assumption

Single fault (1 and extreme value)

Multiple fault (1+ and extreme value)

•Boundary Value Analysis•Robustness Testing

• Worst-Case Testing• Robust Worst-Case Testing

1) Normal vs Robust value