A common misconception is that test plans must be written just before testing. The logic is that his will save time as the coding would have been completed and it will be very clear as to what is to be tested. The logic may work from a project scheduling point of view but not from a quality point of view.
From a quality point of view, test plans must be written as soon as the specifications are ready. If the test plans are written early in the life cycle the errors in the specifications are found before the start of coding. The cost of correcting this error is much lower than correcting the program after it is written. The downside of this logic is that the test plans have to be modified whenever there is a change in requirements. If you take an overall picture, the benefits of writing test plans as early as possible far outweigh the associated costs.
When are Test Plan written