Startup & Shutdown

Discussion in 'Ruby' started by Rajesh Huria, May 27, 2011.

  1. Rajesh Huria

    Rajesh Huria Guest

    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
     
    Rajesh Huria, May 27, 2011
    #1
    1. Advertising

  2. Rajesh Huria

    Rajesh Huria Guest

    Rajesh Huria, May 27, 2011
    #2
    1. Advertising

  3. Rajesh Huria

    Kouhei Sutou Guest

    Hi,

    In <>
    "Startup & Shutdown" on Fri, 27 May 2011 22:46:20 +0900,
    Rajesh Huria <> 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,
    --
    kou
     
    Kouhei Sutou, May 27, 2011
    #3
  4. Rajesh Huria

    Rajesh Huria Guest

    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 @ http://www.ruby-doc.org/stdlib-1.8.7/ 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???

    --
    Posted via http://www.ruby-forum.com/.
     
    Rajesh Huria, May 27, 2011
    #4
  5. Rajesh Huria

    Kouhei Sutou Guest

    Hi,

    In <>
    "Re: Startup & Shutdown" on Sat, 28 May 2011 00:01:56 +0900,
    Rajesh Huria <> 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 @ http://www.ruby-doc.org/stdlib-1.8.7/ 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,
    --
    kou
     
    Kouhei Sutou, May 28, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert May

    Shutdown a single ASP.net process.

    Robert May, Oct 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    378
    Alvin Bruney
    Oct 19, 2003
  2. JBMC

    Cannot shutdown W3SVC

    JBMC, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    6,949
  3. Pint

    prevent application shutdown

    Pint, Mar 16, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    2,082
    Brock Allen
    Mar 17, 2005
  4. tbone
    Replies:
    3
    Views:
    154
    tbone
    Feb 9, 2006
  5. Larry
    Replies:
    9
    Views:
    305
    samwyse
    Jul 20, 2005
Loading...

Share This Page