From: Ralf Mueller Date: 2012-12-05T19:31:18+09:00 Subject: Re: Unable to run the program. This is a multi-part message in MIME format. --------------030903090509010906030506 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 12/05/2012 10:44 AM, sachin.s32@wipro.com wrote: > > Thanks Ralf.. Its working now after changing the name of "def search to def test_search". > > But want to know why def search didn't work previously. > In general a file with a class definition only does not perform anything. It's just a definition. Your class defines a special unit test case and such classes are handled in a special way by ruby. If you run such a definition, all methods starting with 'test_' are started. This eases the work with unit tests, because the developer does NOT have to write the definitions AND the execution of the test methods, but the definitions only. To keep it flexible, a naming conventions has to exist to destinguish between test methods (which should be executed) and helper methods. There are other special methods like "setup" and "teardown", Have a look a http://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing to take the first steps. hth ralf --------------030903090509010906030506 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 12/05/2012 10:44 AM, sachin.s32@wipro.com wrote:

Thanks Ralf.. Its working now after changing the name of “def search to def test_search”.

 

But want to know why def search didn’t work previously.


In general a file with a class definition only does not perform anything. It's just a definition. Your class defines a special unit test case and such classes are handled in a special way by ruby. If you run such a definition, all methods starting with 'test_' are started. This eases the work with unit tests, because the developer does NOT have to write the definitions AND the execution of the test methods, but the definitions only. To keep it flexible, a naming conventions has to exist to destinguish between test methods (which should be executed) and helper methods. There are other special methods like "setup" and "teardown", Have a look a http://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing to take the first steps.

hth
ralf

--------------030903090509010906030506--