Startup & Shutdown

Hi All,

I am trying to execute the below mentioned code:
require ‘test/unit’

class MyTest < Test::Unit::TestCase

class << self
def startup
puts “startup”

     end

    def shutdown

      puts "shutdown"

    end

end
def setup

puts “Test setup”

end

def teardown

puts “test teardown”

end

def test_test3

puts “test3”

end

def test_test1

puts “test1”

end

def test_test2

puts “test2”

end

end
Actual output:
Loaded suite unit_test_suite
Started
Test setup
test teardown
.Test setup
test1
test teardown
.Test setup
test2
test teardown
.Test setup
test3
test teardown
.
Finished in 0.000313 seconds.
Expected Result:
Loaded suite unit_test_suite
Started
Startup
Test setup
test teardown
.Test setup
test1
test teardown
.Test setup
test2
test teardown
.Test setup
test3
test teardown
Shutdown
Ruby version: ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

why startup and shutdown not getting excuted

gem version: test-unit (2.3.0)

Hi,

In [email protected]
“Startup & Shutdown” on Fri, 27 May 2011 22:46:20 +0900,
Rajesh H. [email protected] wrote:

I am trying to execute the below mentioned code:
require ‘test/unit’

You need to add ‘gem “test-unit”’ before ‘require “test/unit”’:

require ‘rubygems’
gem ‘test-unit’
require ‘test/unit’

class MyTest < Test::Unit::TestCase

end

Thanks,

Hi,

In [email protected]
“Re: Startup & Shutdown” on Sat, 28 May 2011 00:01:56 +0900,
Rajesh H. [email protected] wrote:

thanks a lot buddy… its working now. i would like to know why its not
working when i dont write - gem ‘test-unit’ - i can see the standard
library also has test/unit @ Ruby 1.8.7 Standard Library Documentation but
does not support startup and shutdown. Also, when i am writing require
‘test/unit’, it should work? usually we include gems with this format???

‘require “test/unit”’ only case: Ruby bundled test-unit is
loaded because bundled test-unit is already in $LOAD_PATH.

‘gem “test-unit”; require “test/unit”’ case: ‘gem
“test-unit”’ prepends paths for gem version test-unit (not
Ruby bundled test-unit) to $LOAD_PATH. ‘require “test/unit”’
finds gem version test-unit instead of Ruby bundled
test-unit.

Please try the scripts:

‘require “test/unit”’ only case:
p $LOAD_PATH
require ‘test/unit’
p $LOADED_FEATURES

‘gem “test-unit”; require “test/unit”’ case:
require ‘rubygems’
p $LOAD_PATH
gem ‘test-unit’
p $LOAD_PATH
require ‘test/unit’
p $LOADED_FEATURES

Thanks,

Hi All,

Thanks for your help.
I learned new concept about load_path…
really thankful to you guys…

Regards,
Raj

thanks a lot buddy… its working now. i would like to know why its not
working when i dont write - gem ‘test-unit’ - i can see the standard
library also has test/unit @ Ruby 1.8.7 Standard Library Documentation but
does not support startup and shutdown. Also, when i am writing require
‘test/unit’, it should work? usually we include gems with this format???