Upload
yogesh-yadav
View
229
Download
0
Embed Size (px)
Citation preview
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 1/12
Black Box & White Box Testing
BLACK BOX TESTING:-
1. CAUSE EFFECT GRAPH:
Consider the payroll system of a person:
(a) If the salary of a person is less than equal to Rs. 70,000 and expenses do
not exceed Rs. 30,000 then 10% tax is charged by IT department.
(b) If the salary is greater than Rs.60,000 and less than equal to Rs 2lakhs
and expenses don't exceed Rs. 40,000 than 20% tax is charged by IT
department.
(c) For salary greater than Rs 2 lacks, 5% additional surcharge is also
charged.
(d) If expenses are greater than Rs. 40,000 surcharge is 9%.
Causes Effects
C1 : Salary < =
70,000
C2 : Salary >
60,000 and Salary
< = 2 lacks
C3 : Salary > 2
lacks
C4 : Expenses < =
30,000
C5 : Expenses < =
40,000
C6 : Expenses >
40,000
E1: 10% tax is charged.
E2: 20% tax is charged.
E3: (20% tax) + (5%
surcharge) is charged.
E4: (20% tax) + (9%
surcharge) is charged.
1
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 2/12
Black Box & White Box Testing
AND
AND
AND
AND
2
C
1
C2
C
3
E
2
C
4
E
1
C
6
E
3
E
4
C
5
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 3/12
Black Box & White Box Testing
BOLLEAN FUNCTIONS:
E1: C1 ^ C4
E2: C2 ^ C5
E3: C3 ^ c5
E4: C3^ C6
DECISION TABLE:
C1 C2 C3 C4 C5 C6 E1 E2 E3 E4
T F F T F F T F F F
F T F F T F F T F F
F F T F T F F F T F
F F T F F T F F F T
T T F F F F T F F F
T F F T T F T F F F
F T F T F F F T F F
3
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 4/12
Black Box & White Box Testing
TEST CASES:
TEST
CASES
INPUTS (CAUSES) EXPECTED OUTPUTS
(EFFECTS)Salary Expense
1 Salary < =
70,000
Expenses < =
30,000
10% tax is charged.
.
2 Salary > 60,000
and Salary < =
2 lacks
Expenses < =
40,000
20% tax is charged
3 Salary > 2 lacks Expenses < =
40,000
(20% tax) + (5%
surcharge) is charged
4 Salary > 2 lacks Expenses >40,000
(20% tax) + (9%surcharge) is charged.
4
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 5/12
Black Box & White Box Testing
2. EQUIVALENCE PARTITIONING:
Lets we have to test a five digit number.
Partitions for inputs : Let the inputs is denoted by ‘p’.
p< 10000
p is in between 10000 – 99999
> 99999
P is alphabet
P is floating point number
P is null
Partitions for outputs:
Is five digit number
Is not five digit number
Error message
Test Cases 1 2 3 4 5
5
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 6/12
Black Box & White Box Testing
P 123 24242 -23 34.7 Abc
Expected
output
Is not five
digit
number
Is five digit
number
Is not
five
digit
numb
er
Error
message
Error
message
Test
Case
6 7 8 9 10 11 12
P 435334
10000
-34.32 99999
Gfs123 $@#% null
Expect
ed
output
Is not
five
digit
numb
er
Is five
digit
numb
er
Error
messa
ge
Is five
digit
numb
er
Error
message
Error
message
Error
message
6
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 7/12
Black Box & White Box Testing
2. WHITE BOX TESTING:
Branch and Path Coverage(av);
1 public static double ReturnAverage(int value[], int AS, int MIN, int
MAX){
2 int i, ti, tv, sum;
3 double av;
4 i = 0; ti = 0; tv = 0; sum = 0;
5 while (ti < AS && value[i] != -999) {
6 ti++;
7 if (value[i] >= MIN && value[i] <= MAX) {
8 tv++;
9 sum = sum + value[i];
10 }
11 i++;
12 }
13 if (tv > 0)
14 av = (double)sum/tv;
15 else
16 av = (double) -999;
17 return (av);
18 }
7
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 8/12
Black Box & White Box Testing
8
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 9/12
Black Box & White Box Testing
Varibles definitions P-use C-use
value[] 1 5,7 9
AS 1 5
MIN 1 7
MAX 1 7
i 4 11ti 4 5 6
tv 4 13 8
Sum 4 9,14
av 14,16 17
Du Pairs:
9
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 10/12
Black Box & White Box Testing
1,5 & 1,7 : p-use of value[]
1,9: c-use of value[]
1,5: p-use of AS
1,7: p-use of MAX
1,7: p-use of MIN
4,11: c-use of i
4,5: p-use of ti
4,6: c-use of ti
4,13: p-use of tv
4,8 c-use of tv
4,9 & 4,14 c-use of sum
14,17 &16,17 c-use of av
10
8/3/2019 Testing Sweng
http://slidepdf.com/reader/full/testing-sweng 12/12
Black Box & White Box Testing
TEST CASES( ALL C-USE)
TEST CASE#
VARIABLES DU-PAIRS
SUBPATHS
INPUT OUTPUTS
(PUSHOUTPUT
S)
1 Value 1,9 1-9 Values at
value[i]
Takes the
values at ith
position of
array
2 i 4,11 4-11 Integer
value
Increments i
3 Tv 4,8 4-8 Integer
value
Increments tv
4 Sum 4,9 4-9 Integer
value
Adds to the
sum
5 Sum 4,14 4-14 Integer
value
Adds to the
sum
6 Av 14,17 14,15,16,17
Takes theComputed
the value
Returns thevalue
7 av 16,17 16,17 Takes the
Computed
the value
Returns the
value
12