Ian Hobson schreef: > Build up a suite of tests and the code in parallel, like this. > > 1) Think of a very simple case that isn't yet covered by your code. > Start with a very simple cases, and proceed to edge cases and > pathological cases. > > 2) Write a new test to run your code and test the result, and run it. It > will fail, because you HAVE NOT YET WRITTEN THE CODE. (If it doesn't > fail, you have made a mistake somewhere). > > 3) Alter your code to pass the new test and all of the old ones. Only > when this is the case, may you proceed to stage 4. > > 4) Improve you code in some small way - Remove duplicate code, repair a > bad choice of variable names etc. > > 5) After each improvement, Rerun all the tests. If any fail, you > introduced an error. Fix before proceeding. > > 6) When the all pass and your code is nice and clean, save code (and > tests) to the version control system. > > 7) If the code is not yet complete, go to step 1. > > The key is to go in really tiny baby steps at stages 1 and 4, and to > push stage 4 until you have really nice code you would be proud to show > anyone. Note - you are testing for anything that might break/be broken, > not aiming for 100% code coverage. > > You will find that defining the tests will clarify your thinking about > what is required. Stage 4 means the code remains clean and easy to > modify. The test suite will stop you introducing errors into your code > later. > > When you are done, you have nice code, that you can demonstrate is correct. > > Regards > > Ian Hi Ian, As I am a relative beginner do you know any sites/articles/tutorials on test driven development? All I could find was sites on the benefits of tdd but not a tutorial within the ruby language.. found a few in Java I have manually tested all classes I write until now which is a bit tedious and time consuming.. I had a quick look at the test/unit Rdocs but am not quite certain on how to use them Eelco