Test::Unit: multiple level of testing

Discussion in 'Ruby' started by David Garamond, Feb 28, 2004.

  1. I'd like to get suggestions on how to use Test::Unit to fulfill the
    following requirement simply and elegantly:

    Each component (basically a Class, which most of the time reside in a
    single source file) will have a unit test. There should be three levels
    of unit testing:

    1) normal level, which will be executed regularly during development.
    This is basically "the" unit test as we usually understand and use. It
    should do functional and regression testing for each and every method,
    to make sure each functionality is implemented correctly and past bugs
    do not creep in again.

    2) diagnostic level, which will usually be executed if there is
    something wrong going on. This level should include all tests from the
    normal level, but the output/error messages should be more verbose than
    level #1 (under normal circumstances, the verbosity of output/error
    messages from #2 is more than necessary). Additionally, this level
    should also include things like memory leak test, some performance test,
    etc.

    3) same as #2, but more verbose and rigorous. We don't normally run
    tests at these level unless there is problem that can't be tracked using
    #1 and #2.

    --
    dave
     
    David Garamond, Feb 28, 2004
    #1
    1. Advertising

  2. On Sat, 28 Feb 2004 22:58:17 +0900, David Garamond wrote:

    > I'd like to get suggestions on how to use Test::Unit to fulfill the
    > following requirement simply and elegantly:
    >

    [snip]
    > 1) normal level,
    > 2) diagnostic level,
    > 3) same as #2, but more verbose and rigorous.


    May I suggest that you have 3 files which does test_all, but with the
    above levels of debugging enabled.

    My test_all file does verbose integrity checks.. but doesn't output
    anything. Its better to do too many tests than too few, watch out having 3
    levels of tests.

    Though I usually have 2 levels of console-output.. verbose and normal

    # FILE='common.rb'
    class TestCase < Test::Unit::TestCase
    def self.run
    require 'test/unit/ui/console/testrunner'
    Test::Unit::UI::Console::TestRunner.run(self, Test::Unit::UI::VERBOSE)
    end
    end

    # FILE='test_helloworld.rb'
    require 'common'
    class TestScanner < Common::TestCase
    def test_hello1
    end
    end
    TestScanner.run if $0 == __FILE__


    So that when I invoke the 'test_helloworld.rb' I get verbose output.
    When I invoke 'test_all' I get normal output

    --
    Simon Strandgaard
     
    Simon Strandgaard, Feb 29, 2004
    #2
    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. Edvard Majakari
    Replies:
    4
    Views:
    706
    Edvard Majakari
    Feb 25, 2005
  2. kathy
    Replies:
    0
    Views:
    1,401
    kathy
    Aug 2, 2011
  3. Johan Holmberg
    Replies:
    7
    Views:
    183
    Johan Holmberg
    Sep 15, 2003
  4. Bill Mosteller
    Replies:
    0
    Views:
    249
    Bill Mosteller
    Oct 22, 2009
  5. timr
    Replies:
    2
    Views:
    179
Loading...

Share This Page