To give you a slightly better understanding of the differences
between black-box testing and white-box testing, I am going to provide you
a couple of simple examples that illustrate the, the strengths and
limitations of these two techniques. So, in this case, let's start
with black-box testing, so we're only working with this specification.
So, let's say that our specification says that this is a
program that inputs an integer value and prints it. And implementation,
we don't know because we're working at the black box level.
If we wanted to test this function according to its
specification, what we will probably do is to select a positive
integer, a negative integer, and the zero as test inputs
and see how the program behaves for these inputs. So let
me now show you a possible implementation for this specification.
What I'm showing here is this function that we called print
NumBytes, which takes the parameter and prints it. And one thing
that we notice right away is that, although in the specification,
numbers that are less than 1024 and numbers that
are greater or equal to 1024 are exactly equivalent from
the specification standpoint. They're however treated differently in the
code, so the developer decided that the program was just
going to print the value of the parameter if it's
less than 1024. But it was actually divided by 1024
and printing it with a kilobyte mark after it
if you are greater than 1024. And notice that here,
there is a problem. The developer, just a number 124, instead
of 1024. So there's probably a typo in this point in the
code. So this is a case in which by simply doing black-box
testing, so by simply looking at the specific issue, we might miss
this problem. Because we have no reason to consider numbers that are
less than 1024 or greater than 1024. However if we were to
look at the code, so operating at white-box manner, we will right
away see that we need to have a test case that checks
the program when the parameter is greater than 1024. And we will find
the problem right away. So now let me show you a dual example.