We’re going global with this baby…

A discussion recently started on the comp.lang.ruby mailing-list about the
possibility to

port TestNG to Ruby

While Ruby doesn’t support annotations natively, it’s actually quite easy to
simulate and both Aslak and a participant
of this thread have posted a technique to add annotations to Ruby.  For

config :after_test => true
def teardown
  puts "Test2#teardown called"

test :groups => [‘one’]
def test_method1
  puts "Test2#test_method1 called"

This trick relies on the fact that it’s possible to add definitions to
in Ruby.  The annotations config and test
above are actually real methods that update fields added to the Class
class.  When one of these methods is encountered in a Class
definition, it is parsed and then silently discarded so it never actually gets
added to the Class definition.  This is made possible by
overriding the method_added method of the Class class, where
you can control what to do whenever a new method definition is found by the

You can find the full listing for an example implementation of this technique

this message from Ryan Leavengood

I also suggested to replace testng.xml with a Ruby file containing
these definitions (the Ruby community is usually not very friendly to XML file,
and I can certainly sympathize with this feeling).

I’m curious to see where all this will lead…