Chapter 7. Testing and Debugging


If you are skimming this book, you might be tempted to skip over this chapter. After all, why read about testing until you have an application to test? And why worry about debugging techniques until something goes wrong? The answer is simple: testing and debugging are activities that should be happening at every stage of developmentpossibly even before development. Why? Several reasons. It's not surprising that thoroughly tested code will be more reliable, but what might be surprising is that writing tests can actually speed up development. It's counterintuitive, but true because testing acts like a climbing harness: with a reduced penalty for making mistakes, you are freer to make bold, quick moves.

Automated testing is done in every language and platform. But not every technology community places equal weight on the importance of testinga prime example being JavaScript, which is very often written with no tests at all. Fortunately, the Ruby and Rails communities both have a strong culture of testing. A large percentage of Ruby projects include a test suite, and Rails itself has a very thorough one. Rails also encourages developers to test their own applications. Ever notice how script/generate adds little test stubs for every model and controller you generate? That's Rails' way of reminding you to test your code early and often.

Ajax adds a new twist to testing and debugging, and it can often be a major source of frustration. In this chapter, we'll explore the tools and techniques that will help make your application stronger and your life easier.

Given the wealth of tools that support programming in Ruby and other languages, working in JavaScript can be a frustrating experience. Fortunately, there are a growing number of development-support tools to make your work more productive.

In this chapter, we'll first look at debugging tricks and tools, then testing techniques, and finally a couple of ways to catch any remaining bugs that fall through the cracks.




Ajax on Rails
Ajax on Rails
ISBN: 0596527446
EAN: 2147483647
Year: 2006
Pages: 103
Authors: Scott Raymond

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net