Whitebox Testing

# Whitebox Testing - Code Coverage as a Measure of Test Goodness

Created 3 years ago

Duration 0:05:32
257
Slide Content
1. ### Slide 1 - Whitebox Testing:Code Coverage as a Measure of Test Goodness

• Emerson Murphy-Hill
• Material Produced by NCSU Software Engineering Faculty.
2. ### Slide 2 - 100% Method Coverage

• All methods in all classes have been called
• Test case 1: Foo(0, 0, 0, 0, 0) = 0.0
• float foo (int a, b, c, d, e) {
• if (a == 0) {
• return 0.0;
• }
• int x = 0;
• if ((a==b) OR ((c==d) AND bug(a) )) {
• x =1;
• }
• e = 1/x;
• return e;
• }
3. ### Slide 3 - 100% Statement Coverage

• All statements executed
• Test case 1: Foo(1, 1, 1, 1, 1) = 1.0
• float foo (int a, b, c, d, e) {
• if (a == 0) {
• return 0.0;
• }
• int x = 0;
• if ((a==b) OR ((c==d) AND bug(a) )) {
• x =1;
• }
• e = 1/x;
• return e;
• }
4. ### Slide 4 - 100% Branch/Decision Coverage

• Both branches in all control structures executed
• Test case 3: Foo(1, 2, 1, 2, 1)  division by zero!
• float foo (int a, b, c, d, e) {
• if (a == 0) {
• return 0.0;
• }
• int x = 0;
• if ((a==b) OR ((c==d) AND bug(a) )) {
• x =1;
• }
• e = 1/x;
• return e;
• }
5. ### Slide 5 - 100% Condition Coverage

• All sub-expression predicates have been true and false
• Test case 4: Foo(1, 2, 1, 1, 1)  a bug!
• float foo (int a, b, c, d, e) {
• if (a == 0) {
• return 0.0;
• }
• int x = 0;
• if ((a==b) OR ((c==d) AND bug(a) )) {
• x =1;
• }
• e = 1/x;
• return e;
• }