0

Is possible to find an error with white box testing that cannot be found with black box testing?

If it is, then why?

As I understand it, this is not possible, but I'd like to know for sure.

Toby Speight
  • 27,591
  • 48
  • 66
  • 103

1 Answers1

1

I can give this a go.

The answer could be "no" in the sense that if you provide every possible input for an action you can verify whether or not the application behaves correctly in all possible situations, so black box testing would find every bug eventually.

But in reality providing every single possible input for every single possible action is not easy to achieve (or impossible all together sometimes). In other words, it is very hard to write a test for every single possible path in your application's code without even seeing the code. White box testing is much more efficient in catching weird cases because you can see the implementation. A very simple example would be that you know the border cases in a particular if statement.

Let's say that you have a very basic program that has a snippet of code like this:

if (input < 0) {
   print("Input is negative");
} else if (input >= 0 && input <= 60) {
   print("Input is between 0 and 60, inclusive");
} else if (input > 60 && input < 70) {
   print("Input is between 50 and 70, exclusive); //error
} else {
   print("Blah");
}

With white box testing it is very easy to cover all the branches. You know that the set [-1, 5, 65, 80], for example, will hit all the branches, and then you would find the error in the third branch. With black box testing you have no idea what the branch conditions are. You might guess that [0, 5] will hit all the branches. Or you might guess than [0, 1, 56, 67, 454, 45454, 454545454] will hit all the branches. To be sure you have hit all the branches and none of them have bugs you would have to input every number which is impossible.

I'm not saying that every application has complete code coverage, this is far from true. But going back to original question:

Is possible to find an error with white box testing that cannot be found with black box testing?

If you wanted to prove that the answer is "no" just for a single program, you would have to have complete code coverage using black box testing only. This might be doable in very trivial programs but it will quickly escalate to almost being impossible as your program grows more complex.

Zarwan
  • 5,537
  • 4
  • 30
  • 48