Some things need to be said through experience for people to appreciate. I will specify a few reasons why one should test their code from experience. After all it is sometimes better to learn from experience other than following some stated thoughts. The fact is that i have always hated testing code but now i understand why it is very important because i have done it and i have been doing. Previously i hated to test code because i saw that it was wastage of my time. Another important reason was that i didnt know when to use some tools for testing. ie When to test the whole app (integrating testing) and when to test small parts of the app (unit testing). I use Ruby on Rails (ROR) for my web apps these days. so for those of you who use this language you know that cucumber and rspec are the two common gems used for testing.
You should test. The first rails project I worked on was a social network app. I admit, I wrote terrible code in that project. I have been a preacher of NO WRITING TESTS. I appreciate the beauty of testing in the following ways;
- It makes you build confidence in your project in that you will never worry about your program or app failing at any given moment or during demos.
- I discovered that a person who does not write test might fail to see some things as a result of change in their code that could affect the entire app.
- Tests enable you to simulate even things that would require internet such as testing for emailing functionality within your app.
- Most importantly, Debugging is very easy.