From: darren kirby Date: 2007-09-07T13:40:55+09:00 Subject: Re: help me condence my code? quoth the Simon Schuster: > eek. I've never written a unit test before. that's all incredibly > murky territory.. not only am I new to ruby, but new to programming in > general. I'll get around to it someday, I think. it just seems scary. I used to think that too, but finally I got around to trying them, and they really aren't that difficult at all. You basically just call functions which compare known, good values against the values your code generates. The various canned functions allow you to test almost anything your code ought to be doing. The Pickaxe book has a great introduction that lays it out simply and succinctly. You owe it to yourself to check it out...[0] As I discovered, when you start writing libraries or apps of any appreciable size the tests become almost indispensable. You will know immediately if any changes you made broke something anywhere in the code. I have heard of folks who write unit tests directly from their application's specs before they even start on code for the app itself. Then, it's simply a matter of making tests pass, and when they all pass, your done! Truthfully, that's what I find murky and scary ;) -d [0] Sorry, was going to link to it but it seems that the chapter on unit tests was added in the second ed. Guess you will have to buy it ... it's worth it, trust me ;) -- darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." - Dennis Ritchie and Ken Thompson, June 1972