Sunday, January 22, 2006

Another reason why you can't prove code through testing

Why isn’t it possible to prove that a program is correct by testing it? To use testing to prove that a program works, you’d have to test every conceivable input value to the program and every conceivable combination of input values.
-- Steve McConnell, Code Complete, 2nd edition, Microsoft Press

It may be impossible to try every combination of inputs, but testing ‘normal’ input and edge cases is usually a safe way of avoiding a for() loop from -INT_MAX to INT_MAX. There’s another reason you can’t be sure that your tests have proved the code correct, however: the code you are calling may retain state.

No comments:

Post a Comment