August 04, 2005

TestNG in Ruby

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 example:

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

test :groups => ['one']
def test_method1
  puts "Test2#test_method1 called"
end

This trick relies on the fact that it's possible to add definitions to Class 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 parser.

You can find the full listing for an example implementation of this technique in 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...

 

Posted by cedric at August 4, 2005 09:10 AM
Comments

Lately I have been reading some blogs about the relative merits of various scripting languages. I see many performance comparisions and debates made between Python, Perl, TCL, Ruby and Java. However, I cannot remember even one instance where Euphoria was included. I would like to know why the Euphoria programming language never seems to get considered as a viable contender in any of these discussions.

Posted by: John Rogers at August 4, 2005 09:20 AM

re: Euphoria

Probably because most people never even heard of it. There are literally thousands of scripting languages available. Only a half dozen at best will ever be commonly known.

Oh, and the quality of the scripting language has little to do with it's popularity.

Posted by: Funky Monkey at August 4, 2005 02:03 PM

In the same vein, I would like to know why Ecstasy was not included. This was a scripting language I wrote for a term project back in college.

Posted by: Sumit at August 4, 2005 02:40 PM

Cedric,

Please give me a project.

Thanks,
-Michael

Posted by: Michael Kovacs at August 4, 2005 06:20 PM

Sir u have to gime me Java project!
I'm waiting

Posted by: Puroshatttam at August 5, 2005 06:38 AM

I *am* anxiously waiting for the Malbolge port (http://www.lscheffer.com/malbolge.html)

Posted by: Alain Rogister at August 5, 2005 12:05 PM

The Malbolge port, yu Indians, might be an excellent project.

Posted by: Sumit at August 5, 2005 07:33 PM
Post a comment






Remember personal info?