At first, it is easy to add tests. When there are no tests, start covering your most important functionality.
And as bugs are found and fixed, new tests are added. (Every bug should generate at least one new test - the one that proves it has been fixed.)
After testing has reached a more advanced stage, there are tools that can show you what code remains untested. Then you can craft specific tests to excersize that code. By measuring the code base, you can ensure that all of your code is tested.
But it does not guarantee that the code is bug free. Bugs are sneaky things - they can be in tests as well as the code, and they can depend on input data that the tests don’t attempt to use.
A Word of Warning
Testing is wonderful and necessary. Reaching 100% test coverage on a code base (or getting close to it) is a great feeling. Such code is really much better tested than code with no tests, or few tests.
But it does not guarantee that the code is bug free. Bugs are sneaky things - they can be in tests as well as the code, and they can depend on input data that the tests don’t attempt to use.
No comments:
Post a Comment