# Whitebox Testing Fra: CS2335 - Fall 2002. Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are.

## Presentation on theme: "Whitebox Testing Fra: CS2335 - Fall 2002. Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are."— Presentation transcript:

Whitebox Testing Fra: CS2335 - Fall 2002

Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are in the control structure or data path Generates test cases to test control paths through the code Criteria includes Control-Flow and Data-Flow based coverage

Coverage Criteria Control Flow based: Statement Coverage (All nodes) Branch (or Decision) Coverage (All edges) All Paths Data Flow based: All DU paths All C uses All Defs Etc…

Unit Module Specification Invoices are calculated using the following algorithm: Item X sells for \$5 and Item Y sells for \$10 Invoice Total >=\$200 get 5% discount Invoice Total >=\$1000 get 10% discount Invoices that order more than 30 X items get a 5% discount

Example Program int invoice (int x, int y) { int d1, d2, s; if (x<=30) d2=100; else d2=90; s=5*x + 10 *y; if (s<=200) d1=100; else if (s<=1000) d1 = 95; else d1 = 80; return (s*d1*d2/10000); } if d2=100d2=90 if d1=100 if d1=95 d1=80 return x>30 s>200 s>1000

Statement Coverage if d2=100d2=90 if d1=100 if d1=95 d1=80 return x>30 s>200 s>1000 Test CaseExpected Output X=5 Y=575 X=31 Y=10229.5 X=30 Y=100977.5

Branch Coverage Test CaseExpected Output X=5 Y=575 X=31 Y=10229.5 X=30 Y=100977.5 if d2=100d2=90 if d1=100 if d1=95 d1=80 return x>30 s>200 s>1000

Path Coverage if d2=100d2=90 if d1=100 if d1=95 d1=80 return x>30 s>200 s>1000 With loops impossible 6 Test Cases

Download ppt "Whitebox Testing Fra: CS2335 - Fall 2002. Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are."

Similar presentations