From: Eric Hodel Date: 2005-11-15T07:02:49+09:00 Subject: Re: Putting unit test cases in the code - RDoc & UnitTest On Nov 14, 2005, at 7:32 AM, listrecv@gmail.com wrote: > Hi. I find that the best place to put unit test cases is in the file > for the class being tested itself. This puts everything in the same > place, and also makes examples readily available for someone trying to > understand the code. So does creating a file per class and placing tests into identically named files with test_ on the front. This also makes it easy for testrb to pick up your tests and make things Just Work� > Question 1: Can I do this without having Test::Unit automatically run > the tests, every time the file is require 'd? You need to not require test/unit. This is best done by placing tests in their own files. > Question 2: How can I do this so that RDoc shows the examples in the > generated documentation? Put the tests in their own file and point RDoc at your test files. Typically I've found examples are best placed in the class and method documentation because tests can provide an overwhelming amount of information. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04