Perl Best Practices
18.1. Test Cases
Write the test cases first. Probably the single best practice in all of software development is writing your test suite first. A test suite is an executable, self-verifying specification of the behaviour of a piece of software. If you have a test suite, you canat any point in the development processverify that the code works as expected. If you have a test suite, you canafter any changes during the maintenance cycleverify that the code is still working as expected. So write the tests first. Write them as soon as you know what your interface will be (see "Interfaces" in Chapter 17). Write them before you start coding your application or module. Because unless you have tests, you have no unequivocal specification of what the software is supposed to do, and no way of knowing whether it does it. |