Test::Unit non-auto-run test case?

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default Test::Unit non-auto-run test case?

    I'm getting a handle on the Test::Unit library, and the
    automatically-running test case example was extremely simple to get
    running, but now I want to switch my test cases to something
    less-automatic so I can invoke the tests I want programatically.

    I've seen this example:

    require 'test/unit/testsuite'
    require 'tc_myfirsttests'
    require 'tc_moretestsbyme'
    require 'ts_anothersetoftests'

    class TS_MyTests
    def self.suite
    suite = Test::Unit::TestSuite.new
    suite << TC_MyFirstTests.suite
    suite << TC_MoreTestsByMe.suite
    suite << TS_AnotherSetOfTests.suite
    return suite
    end
    end
    Test::Unit::UI::Console::TestRunner.run(TS_MyTests )


    .... but it makes little sense to me in the context of the classes I have
    defined (which are all derived from Test::Unit::TestCase).

    If I don't require 'test/unit' then I get an error message which says
    "undefined superclass `TestCase'", telling me that Test::Unit::TestCase
    is defined in 'test/unit'. If I require that file, the tests all run
    automatically. If I don't, I get an error message.

    So ... what am I missing? I can't find any documentation on this and my
    usual battery of trial-and-error attempts aren't leading me forward.

    Sean O'Dell

    Sean O'Dell Guest

  2. Similar Questions and Discussions

    1. Test::Unit -- multiple errors in test method ???
      Hi ! I have been writing some unit tests with Test::Unit. I've noted that when an assertion fails in a test method, the remaining assertions...
    2. Test::Unit in 1.8
      So far I've noticed two changes in the Test::Unit included with 1.8. They've probably been in Test::Unit for I long time, but I'm just encountering...
    3. Method test::unit::TestSuite#<<(test)
      Hi, I suggest to change the definition of this method slightly: current: # Adds the test to the suite. def <<(test) @tests << test end
    4. Test order in Test::Unit
      On Sun, Jul 06, 2003 at 02:05:57AM +0900, Nathaniel Talbott wrote: instance_eval is also extremely useful; it lets you get at instance variables...
    5. Test::Unit GUI
      nathaniel@NOSPAMtalbott.ws (nathaniel@NOSPAMtalbott.ws) wrote: Hello Nathaniel! Have you considered to include gtk2 patch for Test::Unit...
  3. #2

    Default Re: Test::Unit non-auto-run test case?

    Geez, my code was failing for one stupid typo that didn't syntax error
    but instead caused my TestSuite class to not properly build the
    self.suite array return value. So, uhm ...

    HEY WHAT'S THAT UP OVER THERE! LOOK!

    /runaway

    Sean O'Dell

    Sean O'Dell wrote:
    > I'm getting a handle on the Test::Unit library, and the
    > automatically-running test case example was extremely simple to get
    > running, but now I want to switch my test cases to something
    > less-automatic so I can invoke the tests I want programatically.
    >
    > I've seen this example:
    >
    > require 'test/unit/testsuite'
    > require 'tc_myfirsttests'
    > require 'tc_moretestsbyme'
    > require 'ts_anothersetoftests'
    >
    > class TS_MyTests
    > def self.suite
    > suite = Test::Unit::TestSuite.new
    > suite << TC_MyFirstTests.suite
    > suite << TC_MoreTestsByMe.suite
    > suite << TS_AnotherSetOfTests.suite
    > return suite
    > end
    > end
    > Test::Unit::UI::Console::TestRunner.run(TS_MyTests )
    >
    >
    > ... but it makes little sense to me in the context of the classes I have
    > defined (which are all derived from Test::Unit::TestCase).
    >
    > If I don't require 'test/unit' then I get an error message which says
    > "undefined superclass `TestCase'", telling me that Test::Unit::TestCase
    > is defined in 'test/unit'. If I require that file, the tests all run
    > automatically. If I don't, I get an error message.
    >
    > So ... what am I missing? I can't find any documentation on this and my
    > usual battery of trial-and-error attempts aren't leading me forward.
    >
    > Sean O'Dell
    >
    Sean O'Dell Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139