From: Jason Roelofs Date: 2008-01-03T04:08:34+09:00 Subject: Re: Dynamically add a method to a TestCase ------=_Part_29839_25329527.1199300912681 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Jan 2, 2008 2:06 PM, Jason Roelofs wrote: > On Jan 2, 2008 1:55 PM, Achim Domma wrote: > > > Hi, > > > > I'm experimenting with the dynamic features of ruby to add methods to > > a TestCase. Here is my test script: > > > > require 'watir' > > require 'test/unit' > > > > class MyTest < Test::Unit::TestCase > > end > > > > for num in ["a","b","c"] > > MyTest.send(:define_method,"test_" + num) { > > assert(false,"->"+num) > > } > > end > > > > It works fine so far, but all asserts display "->c" as error message. > > I don't understand why! Any hint? How to fix it? > > > > regards, > > Achim > > > > That's exactly what you're telling assert to do. Method definition is > something like: > > assert(expression, error_message = nil) > > What exactly are you wanting to do? > > Jason > > Dah crap, excuse my previous email. I need to work on my reading comprehension. That is odd. I would assume that a puts there would always say "c", though it can't hurt to try. Jason ------=_Part_29839_25329527.1199300912681--