black box and white box examples
TRANSCRIPT
Black-box Testing
0 Two main approaches to design black box test cases:
0 Equivalence class partitioning
0 Boundary value analysis
Gurbakash Phonsa
Example
In a computer store, the computer item can have a quantity between -500 to +500.
Define equivalence classes for above scenario?
Gurbakash Phonsa
Solution
Valid class: -500 <= QTY <= +500Invalid class: QTY > +500Invalid class: QTY < -500
Gurbakash Phonsa
Example
Account code can be 500 to 1000 or 0 to 499 or 2000 (the field type is integer). What are the equivalence classes?
Gurbakash Phonsa
Solution
Valid class: 0 <= account <= 499
Valid class: 500 <= account <= 1000
Valid class: 2000 <= account <= 2000
Invalid class: account < 0
Invalid class: 1000 < account < 2000
Invalid class: account > 2000
Gurbakash Phonsa
White-Box Testing
There exist several popular white-box testing methodologies:
0 Statement coverage
0 branch coverage
0 path coverage
0 condition coverage
0 mutation testing
0 data flow-based testing
Gurbakash Phonsa
Example0 int f1(int x, int y){ 0 1 while (x != y){0 2 if (x>y) then 0 3 x=x-y;0 4 else y=y-x;0 5 }0 6 return x; }
Gurbakash Phonsa
Statement testing:: Test cases
0 By choosing the test set
{(x=3,y=3),(x=4,y=3), (x=3,y=4)}
0All statements are executed at least
once.
Gurbakash Phonsa
Branch Coverage
0Test cases are designed such that:
0Different branch conditions
0Given true and false values in turn.
Gurbakash Phonsa
Branch Coverage
0 Branch testing guarantees
statement coverage:
0A stronger testing compared to
the statement coverage-based
testing.
Gurbakash Phonsa
Example
int f1(int x,int y){ 1 while (x != y){2 if (x>y) then 3 x=x-y;4 else y=y-x;5 }6 return x; }
Gurbakash Phonsa
Example
0 Test cases for branch coverage can be:
{(x=3,y=3),(x=3,y=2), (x=4,y=3), (x=3,y=4)}
Gurbakash Phonsa
Condition Coverage
0 Test cases are designed such that:
0Each component of a composite
conditional expression
0Given both true and false values.
Gurbakash Phonsa
Example
0 Consider the conditional expression 0((c1.and.c2).or.c3):
0 Each of c1, c2, and c3 are exercised at least once, 0i.e. given true and false values.
Gurbakash Phonsa