Black-Box Boundary Testing (PowerPoint Slides)
-
Upload
softwarecentral -
Category
Documents
-
view
1.645 -
download
0
Transcript of Black-Box Boundary Testing (PowerPoint Slides)
CIS 4932Software Testing
Boundary Testing Approach
2/2000 Unit Test Concepts 2
BOUNDARY TESTING DESIGN METHODOLOGY
• Specification
• Identify elementary boundary conditions
• Identify boundary points
• Generate boundary test cases
• Update test script (add boundary cases).
2/2000 Unit Test Concepts 3
(1) Specification
• Compute pay for an hourly employee, given the number of hours worked and the hourly pay rate. Compute overtime at 1.5 times hourly rate for hours in excess of 40.
SoftwareunderTest
Hours Pay
Rate
2/2000 Unit Test Concepts 4
(2) Identify Boundary Conditions
• Condition 1 (bc1): Hours <= 40
• Observations:• Condition taken directly from decision table
2/2000 Unit Test Concepts 5
(3) Identify Boundary Points
• bc1 Boundary Points• Point 1: AT the boundary: Hours = 40
• Point 2: Just INside: Hours = 39
• Point 3: Just OUTside: Hours = 41
• Observations:• The Hours value must be paired with Rate
• Inclusive inequalities have 3 boundary points
2/2000 Unit Test Concepts 6
(4) Generate Test Cases
• Combine Hours boundary points with Rate• Case 1 (AT): Hours = 40, Rate = 10, Pay=400
• Case 2 (IN): Hours = 39, Rate = 10, Pay=390
• Case 3: (OUT): Hours = 41, Rate=10, Pay=415
• Observations:• Test each boundary point individually
• Then consider pair-wise boundary points
2/2000 Unit Test Concepts 7
(5) Update Test Script
StepStimuli Expected Response
Hours Rate Pay =
1
2
30
50 10
10 300
550
3 40 10 400
4 39 10 390
5 41 10 415
2/2000 Unit Test Concepts 8
Your TurnBoundary Testing
c1: Age <= 12 | Y N N
c2: Age > 65 | Y N N
c3: Age > 80 | Y
c4: Weight > 300 | Y N N N N
c5: Weight > 120 | N Y
a1: Pills = 0 | X X
a2: Pills = 1 | X
a3: Pills = 2 | X X
a4: Pills = 2+(W-120)/50 | X
Decision Table:
2/2000 Unit Test Concepts 9
Your Turn (2-3) Boundary Conditions/Points
Boundary Condition Boundary Point (BP)AT IN
bc1:
OUT
bc2:
bc3:
bc4:
bc5:
2/2000 Unit Test Concepts 10
Your Turn(4) Generate Boundary Test Cases
• To create a test case, you must pair an Age with a Weight• Weight boundary point + NOMINAL Age
• Age boundary point + NOMINAL Weight
• OUT Age + OUT Weight A nominal value is one that is not close to a boundary point. For simplicity, use the same nominal value in all test cases.
2/2000 Unit Test Concepts 11
Your Turn(4) Boundary-Nominal Test CasesCondition btc BC Weight Age Expect
Weight>300 1 IN 301 21 0
2 OUT 300 21
Age <= 12 3 IN 220 11
4 AT 12
5 OUT 13
Age > 65 6 IN
7 OUT
Age > 80 9 IN
10 OUT
Weight>120 11 IN
12 OUT
2/2000 Unit Test Concepts 12
Your Turn(4) Out-Out Boundary Test Cases
Condition OUT BP
Weight Age btc Weight Age Expect
>300 <=12 13
>65 14
>80 15
>120 <=12 16
>65 17
>80 18
2/2000 Unit Test Concepts 13
OBSERVATIONS
• Functional testing defines a minimal number of test cases
• Boundary testing adds a large number of test cases, but are EASY to create
• Boundary testing finds lots of errors!
2/2000 Unit Test Concepts 14
BOUNDARIES EXIST FOR
• Optional fields: (present, missing).
• Variable length data: null string, max length
• Database tables: empty
• Searching: first/last position
• File: closed, empty
2/2000 Unit Test Concepts 15
RANDOM TESTING
• Beyond scope of this course
• Generally used to bombard software with inputs
• No effort to identify expected results
• Appropriate for automated load testing, where concern is for capacity/volume.
2/2000 Unit Test Concepts 16
MAIN POINTSBLACK-BOX TESTING
• Black-box = spec-based testing• Tests intentions• Key knowledge = stimuli and responses• Decision table organizes S/R conditions• Boundary testing flushes coding errors• Black-box test case design can drive
software design -- same issues addressed
2/2000 Unit Test Concepts 17
PUTTING IT ALL TOGETHER
• Test design is a systematic process • whether you use decision tables or not, you
must understand the factors influencing and influenced by the behavior of the unit
• The sooner you design test cases, the better• Test design is more crucial than running tests• Reveals assumptions, omissions and errors
• Use test cases during design and coding
2/2000 Unit Test Concepts 18
PUTTING IT ALL TOGETHER
• It's okay to ask "What happens when …?
• Look for test design patterns • Expect certain type units to be tested in a
similar way• A way to identify best practices• Efficiency without cutting corners
• View test design as a "design product", not just a test product!!
2/2000 Unit Test Concepts 19
SOLUTIONS TO EXERCISES
2/2000 Unit Test Concepts 20
Your Turn (Dosage Problem)(2a) Identify Behaviors
CaseExpected
Stimulus Description #Pills
1
2
3
4
5
6
Any Age, Weight>300
Age > 80, any Weight
Age <= 12, Weight <= 300
Age > 65, Weight <= 300
Age 13-65, Weight 120-300
Age 13-65, Weight < 120
0
0
1
2
2+(W-120)/502
2/2000 Unit Test Concepts 21
Your Turn(2b) Decision Table #1
c1: Age <= 12 | Y Y N N N
c2: Age > 65 | Y Y N N N
c3: Age > 80 | Y Y
c4: Weight > 300 | N Y N Y N Y N N Y
c5: Weight > 120 | N Y
a1: Pills = 0 | X X X X X
a2: Pills = 1 | X
a3: Pills = 2 | X X
a4: Pills = 2+(W-120)/50 | X
2/2000 Unit Test Concepts 22
Your Turn (2b) Decision Table #2
c1: Age <= 12 | Y N N
c2: Age > 65 | Y N N
c3: Age > 80 | Y
c4: Weight > 300 | Y N N N N
c5: Weight > 120 | N Y
a1: Pills = 0 | X X
a2: Pills = 1 | X
a3: Pills = 2 | X X
a4: Pills = 2+(W-120)/50 | X
2/2000 Unit Test Concepts 23
Your Turn(3a) Create Test Cases (testset1)
Case 1 2 3 4 5 6 7 8 9
Age 8 12 67 67 81 85 15 28 28
Weight 40 305 180 360 120 315 100 220 320
Pills 1 0 2 0 0 0 2 4 0
•Is more better?
•Every combination of stimuli is tested.
•Each column specifies at least one condition per variable
2/2000 Unit Test Concepts 24
Your Turn(3b) Create Test Cases (testset2)
Case 1 2 3 4 5 6
Age 20 10 70 83 13 30
Weight 310 70 160 150 115 220
Pills 0 1 2 0 2 4
•Is fewer better?
•Not every combination of stimuli is tested. •Test case generation easier when each column specifies
at least one condition per variable
2/2000 Unit Test Concepts 25
Your Turn(4) Write Test Script (testset1)
StepStimuli Pills=
Age
1
2
3
4
5
6
Weight StepStimuli Pills= Age
7
8
9
10
12
Weight
11
8
12
67
81
85
67
28
28
15
315
120360
180
305
40 100
220
320 0
4
2 1
0
2
0
0
0
2/2000 Unit Test Concepts 26
Your Turn(2) Identify Boundary Conditions
• Condition 1 (bc1): Age <= 12
• Condition 2 (bc2): Age > 65
• Condition 3 (bc3): Age > 80
• Condition 4 (bc4): Weight > 300
• Condition 5 (bc5): Weight > 120
2/2000 Unit Test Concepts 27
Your Turn(3) Identify Boundary Points
Boundary Condition Boundary PointAT IN
bc1: Age <= 12
OUT
bc2: Age > 65
bc3: Age > 80
bc4: Weight > 300
bc5: Weight > 120
12 11
66
81
301
121
13
65
80
300
120
2/2000 Unit Test Concepts 28
Your Turn(4) Boundary-Nominal Test Cases
Condition btc BC Weight Age Expect
Weight>300 1 IN 301 21 0
2 OUT 300 21 5
Weight>120 3 IN 121 21 2
4 OUT 120 21 2
Age <= 12 5 AT 220 12 1
6 IN 220 11 1
7 OUT 220 13 4
Age>65 8 IN 220 66 2
9 OUT 220 65 4
Age>80 10 IN 220 81 0
11 OUT 220 80 2
2/2000 Unit Test Concepts 29
Your Turn(4) Out-Out Boundary Test Cases
Condition OUT B-point
Weight Age btc Weight Age Expect
>300 <=12 12 300 13 5
>65 13 300 65 5
>80 14 300 80 5
>120 <=12 15 120 13 2
>65 16 120 65 2
>80 17 120 80 2
2/2000 Unit Test Concepts 30
Your Turn -- White-Box Testing(1) Construct Decision Table
pills=0;if (Age < 80 && Weight <300){ pills=1; if (Age >= 65) pills=2; else if (Age > 12) pills=2+(Weight-120)/50;}return pills;
| Age < 80 | N - Y Y Y
| Weight<300 | - N Y Y Y
| Age >= 65 | N Y N
| Age > 12 | N - Y| Pills = | 0 0 1 2 C--------------
Note: C: 2+(Weight/120)/50
2/2000 Unit Test Concepts 31
Your Turn(2) Derive White-Box Test Cases
Case 1 2 3 4 5
Age 83 24 11 68 35
Weight 97 310 85 225 108
Pills 0 0 1 2 2
| Age < 80 | N - Y Y Y
| Weight<300 | - N Y Y Y
| Age >= 65 | N Y N
| Age > 12 | N Y YPills = | 0 0 1 2 C