Chapter 16. Testing and Debugging
Testing is important. All competent programmers know this fact even if it isn't always at the forefront of their minds.
Of course, true exhaustive testing is usually impossible. A program or system of any significant size is always going to hold a few surprises as it goes through its life cycle. The best we can do is to test carefully and selectively and get as wide a coverage as we can.
Historically, programmers don't always test as adequately as they should. The typical reasons for this are tests that are difficult to set up and run, require manual intervention, or take too long to run.
In the 1990s, a "culture of testing" began springing up in the computing community. The ideas of extreme programming and test-driven development started to gain mind-share among developers everywhere.
Whether you are a hard-core "test first" person is not the point. The point is that everyone can benefit from tests that are automated, easy to write, and easy to run.
Tools such as Test::Unit and the ZenTest tools were easier to write in Ruby because Ruby is dynamic and flexible. In the same way, they are easy to use and (dare I say it?) even fun to use. There is something satisfying about making a software change and then watching every test run to completion and pass.
Besides these testing tools, Ruby also has various other tools and libraries for debugging, profiling, and code coverage. This chapter gives an overview of what is available.