Problems with super

V

Vijay Nyayapati

Hi,

I have been struggling to get super to work.

I have a class A which inherits from Test::Unit::UI::Console::TestRunner

class A has a method 'start' which is trying to override the 'start'
method from the TestRunner class.

so my derived class looks like

require 'test::unit::ui::console::testrunner'

class A < Test::Unit::UI::Console::TestRunner
def start
super
# some code here
end
end

I am running some tests using the Test::Unit framework.

Now, whenever a testsuite runs, i would like the start method from class
A to be invoked when required. Currently, the base class is getting
invoked, which means the start method in the base class is not getting
overridden.

How do i get the start method from class A to get invoked instead of the
start method in the TestRunner class?

Help!
 
T

Trans

Vijay said:
Hi,

I have been struggling to get super to work.

I have a class A which inherits from Test::Unit::UI::Console::TestRunner

class A has a method 'start' which is trying to override the 'start'
method from the TestRunner class.

so my derived class looks like

require 'test::unit::ui::console::testrunner'

class A < Test::Unit::UI::Console::TestRunner
def start
super
# some code here
end
end

Try....

class Test::Unit::UI::Console::TestRunner
alias super_start start
def start
super_super
# some code here
end

T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,142
Members
47,757
Latest member
PDIJaclyn

Latest Threads

Top