Test your code

Development Tips

Setup as many tests as you can for your code. Run tests that are impossible because things will change and those impossible things will happen.


Date : 2006-06-14
Testing is the closest we can get to knowing how code is going to react in production. In production your code will be fed all kinds of junk. Some of it malicious and some of it fairly random.

The simplest form of testing is to create a loop and run your code through it thousands of times with random data. Log everything that happens and then query the log for errors. If your code needs to handle database values run a query and run every single record in the database through the code. Run through values that should break the code and see how it handles them.

Well written code has been through rigorous testing. Then, when you think it's perfect, turn it live and don't be surprised if there are more errors.

Have you Error handling code email you with the details of the error or at least log them, don't wait for confused users to try to communicate the problem to you.

Doing this will allow you to create robust code that can handle any manner of abuse it receives on the internet, or in users hands.

Comments :

No comments yet
  • Search For Articles