From: Gregory Brown Date: 2007-05-21T22:48:54+09:00 Subject: Re: Need some help.. On 5/21/07, Disha Tamhane wrote: > Hi, > > I have a script in one file say "a.rb". > I have another file "tc_a.rb" which is a test case for "a.rb" > I have called a specific script in "a.rb" by using the system() command from > "tc_a.rb" > > Now when i am using rcov to get the code coverage, although an if -else > block in "a.rb" is getting executed, rcov doesn't seem to recognise it... it > still shows the block as not covered...May be because it is getting called > through the system command > > This particular if-else block is an independent one i.e. not present in any > method in "a.rb" > > I need to get this block covered... > > Can someone suggest a solution? Are you doing something like, taking arguments e.g: ARGV[0].do_something and you want to test this? if that's the case, split it up into a library / script combo, and make the functions testable #--------- def do_it(arg) arg.do_something end if __FILE__ == $PROGRAM_NAME do_it(ARGV[0]) end #------ Now you can test the do_it method by just requiring the file. if you do this cleanly enough, there won't be much left to test in your script.