N
Nicholas Van Weerdenburg
Hi all,
test/unit is super cool.I was blown away by how test/unit automatically
looks in ObjectSpace and creates a test suite for all tests found, and
then runs them. I was wondering how it was possible, so I looked at
unit.rb-
at_exit{exit(Test::Unit::AutoRunner.run($0)) unless($! || Test::Unit.run?)}
Cool!
A couple of questions:
1. A more general question: how do I initialize instance variables
without an "initialize" method? In my test case, I want instance
variables, but placing "@myvar=1" outside a method doesn't seem to work
( I dimly recall that this is a class instance variable or something
like that). The reason I want to do this is that in subclassing
Test::Unit::TestCase I don't know offhand what it's initialize method
looks like (a no arg "initialize" gives an argment number error) and
don't want to learn just for this reason.
I just thought of trying the following-
def initialize *args
super *args
@myvar=1
end
and it worked (I think). Cool.
My other option is the setup method, since that is called for before all
test methods. Are there any other options?
2. where do I find the will to return to programming in Java now that
I'm having so much fun in Ruby?
Thanks,
Nick
test/unit is super cool.I was blown away by how test/unit automatically
looks in ObjectSpace and creates a test suite for all tests found, and
then runs them. I was wondering how it was possible, so I looked at
unit.rb-
at_exit{exit(Test::Unit::AutoRunner.run($0)) unless($! || Test::Unit.run?)}
Cool!
A couple of questions:
1. A more general question: how do I initialize instance variables
without an "initialize" method? In my test case, I want instance
variables, but placing "@myvar=1" outside a method doesn't seem to work
( I dimly recall that this is a class instance variable or something
like that). The reason I want to do this is that in subclassing
Test::Unit::TestCase I don't know offhand what it's initialize method
looks like (a no arg "initialize" gives an argment number error) and
don't want to learn just for this reason.
I just thought of trying the following-
def initialize *args
super *args
@myvar=1
end
and it worked (I think). Cool.
My other option is the setup method, since that is called for before all
test methods. Are there any other options?
2. where do I find the will to return to programming in Java now that
I'm having so much fun in Ruby?
Thanks,
Nick