Sunteți pe pagina 1din 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
1

E1: 10% tax is charged. E2: 20% tax is charged. E3: (20% tax) + (5% surcharge) is charged. E4: (20% tax) + (9% surcharge) is charged.

Black Box & White Box Testing

C 1

AND E 1

C 2 AND C 3 E 2

C 4

AND E 3

C 5 AND C 6 E 4

Black Box & White Box Testing

BOLLEAN FUNCTIONS: E1: C1 ^ C4 E2: C2 ^ C5 E3: C3 ^ c5 E4: C3^ C6

DECISION TABLE:

C1 T F F F T T F

C2 F T F F T F T

C3 F F T T F F F

C4 T F F F F T T

C5 F T T F F T F

C6 F F F T F F F

E1 T F F F T T F

E2 F T F F F F T

E3 F F T F F F F

E4 F F F T F F F

Black Box & White Box Testing

TEST CASES:

TEST CASES 1

INPUTS (CAUSES) Salary Salary < = 70,000 Salary > 60,000 and Salary < = 2 lacks Salary > 2 lacks Expense Expenses < = 30,000 Expenses < = 40,000 Expenses < = 40,000 Expenses > 40,000

EXPECTED OUTPUTS (EFFECTS) 10% tax is charged. . 20% tax is charged

(20% tax) + (5% surcharge) is charged (20% tax) + (9% surcharge) is charged.

Salary > 2 lacks

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
5

Black Box & White Box Testing

P Expected output

123 Is not five digit number

24242 Is five digit number

-23 Is not five digit numb er

34.7 Error message

Abc Error message

Test Case P Expect ed output

6 4353 34 Is not five digit numb er

7 1000 0 Is five digit numb er

8 -34.32 Error messa ge

9 9999 9 Is five digit numb er

10 Gfs123 Error message

11 $@#% Error message

12 null Error message

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 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 int i, ti, tv, sum; double av; i = 0; ti = 0; tv = 0; sum = 0; while (ti < AS && value[i] != -999) { ti++; if (value[i] >= MIN && value[i] <= MAX) { tv++; sum = sum + value[i]; } i++; } if (tv > 0) av = (double)sum/tv; else av = (double) -999; return (av); }

Black Box & White Box Testing

Black Box & White Box Testing

Varibles value[] AS MIN MAX i ti tv Sum av

definitions 1 1 1 1 4 4 4 4 14,16

P-use 5,7 5 7 7

C-use 9

11 5 13 6 8 9,14 17

Du Pairs:
9

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

Black Box & White Box Testing


TEST CASES (ALL P-USE):

TEST CASE # 1

VARIABLE S

DUPAIR S 1,5

SUBPATHS

INPUT

OUTPUTS (PUSHOUTP UTS)

Value[]

1,2,3,4,5

Any value not equal to -999 Value greater than MIN and less than MAX Value greater than ti Integer value Integer value Value less than AS Greater than 0

Integer accepted Value accepted

Value[]

1,7

1,2,3,4,5,6,7

3 4 5 6 7

AS MAX MIN Ti tv

1,5 1,7 1,7 4,5 4,13

1,2,3,4,5 1,2,3,4,5,6,7 1,2,3,4,5,6,7 4,5 4,5,6,7,8,9,1 0,11,12,13

Value accepted

Value accepted tv accepted

11

Black Box & White Box Testing


TEST CASES( ALL C-USE)

TEST CASE#

VARIABLES

DUPAIRS

SUBPATH S

INPUT

OUTPUTS (PUSHOUTPUT S)

Value

1,9

1-9

Values at value[i]

Takes the values at ith position of array Increments i Increments tv Adds to the sum Adds to the sum Returns the value Returns the value

2 3 4 5 6

i Tv Sum Sum Av

4,11 4,8 4,9 4,14 14,17

4-11 4-8 4-9 4-14 14,15,16, 17 16,17

Integer value Integer value Integer value Integer value Takes the Computed the value Takes the Computed the value

av

16,17

12

S-ar putea să vă placă și