r/programmerchat • u/gxm492lor • Mar 10 '19
Testing any complex program completely is practically impossible
Someone made this argument after a staff meeting a few days ago. What's wrong with this argument?
Every IF statement in a program doubles the number of possible states of the program (ignoring time)
Which means every IF statement doubles the number of test conditions
A 1 million line program might, conservatively estimating, have 100k IF statements (conditionals)
That is 2100000 which is more seconds than have elapsed since the beginning of the universe.
No project has 2100000 seconds to test
So complete test coverage of complex programs is impossible
1
Upvotes
1
u/gxm492lor Jun 08 '19 edited Jun 08 '19
Look up the halting problem, it doesn't help you.
Intelligent pruning helps but it is still possible: someone can edit the binary directly making all of your previously unreachable states reachable. A flipped bit from cosmic radiation can do the same. A malicious actor can jump into the program in ways that are "impossible"
Also, what % of the conditions in a complex program are terminal?
Let's take a 10 million line program. Let's assume 1/10 are conditionals. So 1 million bits. Complex, long running programs are not likely to devote more than a tenth of its conditionals to immediate termination.
So 2900k. Which is still too many.
We can't even test most of the intentionally reachable states.