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 Mar 10 '19 edited Mar 10 '19
I think the table demonstrates it best.
It's basic math. To fully test 1 IF you need 2 tests (21 ): one when it is true and one when it is false.
To fully test 2 IFs you need 4 tests. This is doubling 22.
To fully test 3 IFs you need 8 tests. All the previous ones with this true and all the previous with this one false.