Hi,
In <a63b1a4a8d55adfcebf38941a6abdce8@ruby-forum.com>
"Re: Test Unit setup teardown problem" on Fri, 29 Jul 2011 20:26:44 +0900,
So what i did is i make that class as module. now the problem is setup
and teardown gets invoked but startup and shutdown method doesn't.
following is the code I am using.
require 'test/unit'
require 'rubygems'
require 'watir'
module BaseClass
class << self
def startup
p "startup"
@browser = Watir::Browser.new
@browser.goto("http://gmail.com")
@browser.maximize
end
def shutdown
p "shutdown"
@browser.close()
end
end
def setup
puts "setup called"
end
def teardown
puts "teardown called"
end
end
DemoTest.rb
require 'Test/BaseClass'
require 'test/unit'
require 'rubygems'
require 'watir'
class DemoTest < Test::Unit::TestCase
include BaseClass
def test_first
puts "first"
end
end
Try this:
require 'rubygems'
gem 'test-unit'
require 'test/unit'
require 'waitr'
module BaseClass
module ClassMethods
def startup
p "startup"
@browser = Watir::Browser.new
@browser.goto("http://gmail.com")
@browser.maximize
end
def shutdown
p "shutdown"
@browser.close()
end
end
class << self
def included(base)
base.extend(ClassMethods)
end
end
def setup
puts "setup called"
end
def teardown
puts "teardown called"
end
end
class DemoTest < Test::Unit::TestCase
include BaseClass
def test_first
puts "first"
end
end
Thanks,
···
Gaurang Shah <shahgomji@gmail.com> wrote:
--
kou