Is it possible to test everything in a program?

Yes. It's expensive, though. One way to do it is to put a breakpoint after every branch, and trace through code. As you see the program go through the breakpoint and execute properly, clear the breakpoint or move it down, as appropriate. When there are no more breakpoints left, every line of the program has been tested. This will generally cost about $5 per line. If you're in a situation where a bug will cost you a few dollars, then spending a million dollars to test the code this way is stupid. On the other hand, if you're in a situation where a bug can kill a hundred people, a million or two in testing is no big deal. We typically use this method in aerospace work.
 
As a general rule, the answer is: no, you can't. Inside most programs, many decisions are made, e.g. based on the input the program receives. Based on the results of the decisions, other decisions may have to be made, and all these may be repeated many times with many different parameters.

Imagine: you have to tell the IRS how much money they've made, how much you spent on tax deductibles, etc. Based on many, many variables, you may have to pay taxes, get a refund, or the IRS may visit you to check your books. The IRS does this for many people, each living in different situations, with different incomes, etc.

This results in too many different possibilities to test. A simple example: a small program may perform 100 IF-THEN-ELSE tests, and each of their outcomes may be based on the outcomes of the tests done before it. That means there are 2 to-the-power-of 100 = 1267650600228229401496703205376 different ways the program can be executed. Even if you could test 1,000,000 different ways per second, testing this program exhaustively would take longer than the Sun will still shine. And this is only a small program...
 
Back
Top