Section 16.1. Testing with Test::Unit


Chapter 16. Testing and Debugging

I've just picked up a fault in the AE35 unit. It's going to go 100% failure in 72 hours.

HAL 9000, in 2001: A Space Odyssey

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.




The Ruby Way(c) Solutions and Techniques in Ruby Programming
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2004
Pages: 269
Authors: Hal Fulton

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