Whitebox Testing - Code Coverage as a Measure of Test Goodness

Whitebox Testing
1.0x

Whitebox Testing - Code Coverage as a Measure of Test Goodness

Created 2 years ago

Duration 0:05:32
lesson view count 256
Select the file type you wish to download
Slide Content
  1. Whitebox Testing:Code Coverage as a Measure of Test Goodness

    Slide 1 - Whitebox Testing:Code Coverage as a Measure of Test Goodness

    • Emerson Murphy-Hill
    • Creative Commons Attribution 4.0 License.
    • Material Produced by NCSU Software Engineering Faculty.
  2. 100% Method Coverage

    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. 100% Statement Coverage

    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. 100% Branch/Decision Coverage

    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. 100% Condition Coverage

    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;
    • }