xhtml
 

Testing

There are two reasons for testing:

The second reason, refactoring, becomes more and more important as your programs get bigger. When you go back to a program to upgrade it, even if there have only been a few days gap, you never read or understand the code as well as you did when you were writing it for the first time. That makes it really easy to introduce new bugs. What is more, you may trigger old bugs which were there all the time, but which you didn't find before. Old bugs are difficult to find because they are not in the new code which you've just written, so you don't where to look for them. That means:

You need to test your code as you write it.

You should save the tests so you can re-run them later when you refactor the code.

Every programmer always tests a program, even if it is just running the program a few times to see if it works. As well as allowing us to break down our programs into manageable pieces, methods also help us with testing. They help us to organise our testing, to use our programming skills to avoid repetition and help make testing as painless as possible, and they help us to save our tests so we can re-run them later.

The next thing we are going to need to do is to develop a strategy to make testing easy.


Back