I'd love to see it's extensions to the standard xUnit style testing
get incorporated into our TestUnit objects...
Anyways, if/when any of you that care to, have the time, please take a
look at TestNG and let me know what you think of the idea of something
like that becoming the standard for Ruby?
Thanks ... I know I'm not in any place of power, but I just wanted to
see what people think.
j.
--
"So long, and thanks for all the fish"
Jeff Wood
http://www.beust.com/testng/ appears to be the home page. What might
be useful is forwarding this to Nathaniel Talbott to see what he's
done toward creating the test/unit next generation code that he
presented last year at RubyConf and maybe see if the ideas with this
can be expressed in code that fits with his ideas. It might also be
worth going over the ideas that he's had with test/unit from last
year's presentation. I *think* Ryan Davis archives the presentations
at zenspider.org.
-austin
--
Austin Ziegler * halos...@gmail.com
* Alternate: aus...@halostatue.ca
I've taken just a very cursory look, but I imagine a Ruby equivalent could
be created fairly easily. In fact, a Ruby version could be much better.
For example, since TestNG test classes do not subclass from anything, one
is required to use the Java assert keyword for all assertions. That means
all those handy assertions provided by JUnit can no longer be used (unless
I missed some trick.) In Ruby, the Test::Unit::Assertions module could
just be mixed into Object and everything could use them.
Another possible issue is the fact that there is no equivalent to Java
annotations, though I've done some prototyping and figured out a way to
fairly easily have the equivalent in Ruby, at least for methods.
Still, I balk when I see XML config files, even if they are fairly simple
Hi!
I am part of the TestNG team and your messages just raised my pulse (pretty happy right now).
I am a newbie to Ruby, but I really think I would like to work with somebody on porting the TestNG
functionality in Ruby.
Please let me know if somebody is interested in guiding me through Ruby. I can pay back with some
TestNG internal ;-).
thanks,
:alex |.::the_mindstorm::.|
I mean, we know that methods are objects, and therefore can have their
own values & methods ( methods on methods ) <evilgrin> ... So, we just
need a good way to provide and use those attributes.
so:
class TestSuite
def testOne() :isa=test , :group="group1","group2"
# do stuff here
end
def testTwo() :isa=test , :group="group1" , :depends_on=testOne
# do stuff here too
end
def runTests()
methods( :isa, "test", :include, "group1", :exclude, "group2" ).run
end
end
The ability to categorize and filter a set of functions... then, to be
able to execute them all one after the other...
.. or something like that.
j.
I don't think so.
> I mean, we know that methods are objects, and therefore can have
> their own values & methods (methods on methods) <evilgrin> ... So,
> we just need a good way to provide and use those attributes.
> so:
> class TestSuite
> def testOne() :isa=test , :group="group1","group2"
> # do stuff here
> end
>
> def testTwo() :isa=test , :group="group1" , :depends_on=testOne
> # do stuff here too
> end
>
> def runTests()
> methods( :isa, "test", :include, "group1", :exclude, "group2" ).run
> end
> end
No need for attributes this way. Try this:
class MyTestSuite
extend Test::Unit::Testable # Hypothetical testable module
test_groups :group1, :group2
test_method
def test_one
# ...
end
test_groups :group1
test_dependency :test_one
test_method
def test_two
# ...
end
end
Alternately:
class MyTestSuite
extend Test::Unit::Testable
test_method :test_one, :groups => [ :group1, :group2 ] do
# ...
end
test_method :test_two, :groups => [ :group1 ], :depends => :test_one do
# ...
end
end
This latter uses a Rake-style test declaration and uses the block as
the test method.
.. I wasn't too far from yours but i agree yours is superiour.
j.
Probably not much different than yours. test_method would add this
information to something attached to the class itself. I was playing
with the idea more than trying to create an implementation. See pages
25 and beyond of Nathaniel Talbott's 2004 presentation:
http://zenspider.com/dl/rubyconf2004/TestUnit.pdf
Is there any metadata that can be associated with a method? I know it is an object, and maybe you
can attach some metadata to it. From that point on the things will be more simple.
:alex |.::the_mindstorm::.|
No, you can't attach metadata to methods, but you can attach them to the
class or module where the methods are defined. I think this should be
enough for something like TestNG. For more info look into the archives
of ruby-talk or ruby-core (I don't remember where).
Regards,
Pit
j.
I think I have tried that article a couple of times, but my Ruby understanding was pretty young at
that moment. Maybe I will try it again.
:alex |.::the_mindstorm::.|
j.
--
Reyn Vlietstra
Does anyone still has the reference to the why blog entry about metadaata? thanks a lot
:alex |.::the_mindstorm::.|
I see there has been quite a few additional discussions of this. I decided
to code up a more thorough prototype of how Java method annotations could
be simulated in Ruby:
class Class
attr_reader :configs, :groups, :test_methods
def config(hash)
@config_method = true
@temp_configs = []
hash.each do |key, value|
if value
@temp_configs << key
end
end
end
def test(hash)
@test_method = true
@current_groups = hash[:groups]
end
def method_added(method)
if @config_method or @test_method
if @current_groups
@groups||={}
@current_groups.each do |group|
(@groups[group]||=[]) << method
end
end
if @config_method
@configs||={}
@temp_configs.each do |config|
(@configs[config]||=[]) << method
end
end
if @test_method
(@test_methods||=[]) << method
end
end
@config_method = false
@current_groups = nil
@temp_configs=nil
@test_method = false
end
end
class Test
config :before_test => true
def setup
puts "Test#setup called"
end
config :after_test => true
def teardown
puts "Test#teardown called"
end
test :groups => ['one']
def test_method1
puts "Test#test_method1 called"
end
test :groups => ['two']
def test_method2
puts "Test#test_method2 called"
end
end
class Test2
config :before_test => true
def setup
puts "Test2#setup called"
end
config :after_test => true
def teardown
puts "Test2#teardown called"
end
test :groups => ['one']
def test_method1
puts "Test2#test_method1 called"
end
test :groups => ['two']
def test_method2
puts "Test2#test_method2 called"
end
end
def run_tests(tests, test_instance, test_class)
tests.each do |method|
if test_class.configs[:before_test]
test_class.configs[:before_test].each do |config_method|
test_instance.__send__(config_method)
end
end
test_instance.__send__(method)
if test_class.configs[:after_test]
test_class.configs[:after_test].each do |config_method|
test_instance.__send__(config_method)
end
end
end
end
if $0 == __FILE__
%w{Test Test2}.each do |klass|
klass = Module.const_get(klass)
test = klass.new
run_tests(klass.test_methods, test, klass)
klass.groups.each do |group, list|
puts "\nTesting group #{group}:"
run_tests(list, test, klass)
end
puts
end
end
__END__
Ryan
I am the creator of TestNG, and this is a very interesting discussion!
I'm a big Ruby fan myself and while I have toyed with the idea of
porting TestNG to Ruby, the need has never presented itself so far.
Good to see this is changing.
I am not too worried about the annotations part, since it can be easily
simulated, either with Ryan's trick above, or with similar ones such as
Aslak's ( http://tinyurl.com/6xjnj ).
The TestNG runtime is fairly heavy, though, although I am convinced it
would be much simpler to implement in Ruby, but it would probably still
represent most of the porting effort, especially if you want to support
some of the advanced functionalities (dependent methods or parallel
runs).
An interesting angle could also be to do away with testng.xml and
replace it with a Ruby definition file, which would probably be easier
to handle.
Feel free to email me if you'd be interested in undertaking such a
project, there has been a lot of progress on the TestNG tools front
these past weeks (IDEA and Maven plug-in mostly) and I would love to
see some of the innovative ideas that we put inside TestNG cross
borders and reach the Ruby community as well.
--
Cedric
http://testng.org
j.
Why couldn't you add metadata to methods?
class Metod
def metadata
@metadata
end
def metadata= data
@metadata = data
end
end
def foo
"foo"
end
foometh = self.method(:foo)
foometh.metadata = "This method just says foo"
puts foometh.metadata #=> This method just says foo
Phil
:alex |.::the_mindstorm::.|
I really think we should keep them together. Otherwise we're just
asking for things to get out of sync.
j.
On 8/4/05, Alexandru Popescu <the_mi...@evolva.ro> wrote:
foometh2 = self.method(:foo)
puts foometh2.metadata #=> nil
The metadata doesn't really stay with the method, only with the Method
instance.
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Even better:
irb(main):001:0> class Object
irb(main):002:1> def metadata
irb(main):003:2> @metadata
irb(main):004:2> end
irb(main):005:1> def metadata= data
irb(main):006:2> @metadata = data
irb(main):007:2> end
irb(main):008:1> end
irb(main):021:0> class Foo
irb(main):022:1> def sayfoo
irb(main):023:2> "foo I said"
irb(main):024:2> end
irb(main):025:1> end
=> nil
irb(main):026:0> Foo.metadata = "This is a Foo class"
=> "This is a Foo class"
irb(main):027:0> Foo.metadata
=> "This is a Foo class"
That way you can put metadata on (just about) any object.
Phil
def foo
foo.metadata = "the foo function"
end
or something like that.
j.