From _A Guide to Testing the Rails_, a fantastic explanation of why we should write test code

Posted by amy on May 17, 2007

As mentioned before, tests offer proof that you’ve done a good job. Your tests become your own personal QA assistant. If you code your tests correctly, at any point in development, you will know:

  • what processes work
  • what processes fail
  • the effect of adding new pieces onto your application

With your tests as your safety net, you can do wild refactoring of your code and be able to tell what needs to be addressed simply by seeing which tests fail.

In addition to normal “did it pass?” testing, you can go the opposite route. You can explicitly try to break your application such as feeding it unexpected and crazy input, shutting down critical resources like a database to see what happens, and tampering with things such as session values just to see what happens. By testing your application where the weak points are, you can fix it before it ever becomes an issue.

A strong suite of tests ensures your application has a high level of quality. It’s worth the extra effort.

Another positive side-effect of writing tests is that you have basic usage documentation of how things work. Simply by looking at your testing code, you can see how you need to work with an object to make it do it’s thing.

The online book is a fantastic resource. Thank you, thank you, Sam-I-Am.

Theoretically Related Posts
  • Testing Rails: the learning curve
  • 12 Steps to Testing in Rails
  • Testing in Rails: Way More Trouble Than Flossing
  • Moved to Wordpress
  • Trackbacks

    Use this link to trackback from your own site.

    Comments

    Leave a response

    Comments