Debug testcase keyword

[snip]

But I don’t like this current approach (files appears to be modified in
CVS). Instead I dream of a ‘debug’ keyword, which would set a debug-flag
variable for the specified methods. I imagine something like:

class TestScanner < Test::Unit::TestCase
include Repeat
debug test_repeat8, test_repeat9
end

I solved it myself… Thanks comp.lang.ruby :wink:

···

On Fri, 07 Nov 2003 13:47:16 +0100, Simon Strandgaard wrote:


Simon Strandgaard

ruby debug_keyword.rb
before
42
after
exp
expand expr
expand -t2 debug_keyword.rb
class Test
def test
puts “42”
end
def self.debug(*methods)
methods.each{|method|
name = method.id2name
org = “debug”+name
module_eval <<MSG
alias #{org} #{name}
def #{name}(*a,&b)
puts(“before”)
#{org}(*a,&b)
puts(“after”)
end
private :#{org}
MSG
}
end
debug :test
end

Test.new.test