07 Glass Box Testing

Advantages:

Glass box testing supplements, it does not replace black box testing.

In glass box testing, our goal is to cover the entire program in test cases. Ensure that the entire program is excercised by tests

Let's make this concrete!

There are only 4 paths this function can take with it's if expressions. Testing along all black-box specifications might lead to all kinds of input, but for glass box testing, we can test with

We then hit every condition in the function! But we haven't really tested against the implementation, so black-box testing is still nessicary.

Include test cases for:

Watch out for:

Let's write a function that determins if a year is a leap year.

Suppose we wrote the test suite with these inputs

What kind of coverage does the test suite achieve?

y mod 4 = 0 y mod 100 <> 0 y mod 400 = 0
2000 true false true.
2010 false Not evaluated. Not evaluated.
2020 true true Not evaluated.

-Statement coverage is acheived by just 200- -Condition coverage is not achieved. No input causes y mod 400 = 0 to evaluate to false. We can add the test case for 2100 to do that!

y mod 4 = 0 y mod 100 <> 0 y mod 400 = 0
2100 true false false.