TestCase human-readable name

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default TestCase human-readable name

    Hello!

    I have a question about TestUnit. How can i set a human-readable name for my
    TestCase? I see name argument for a new, but i don't know where class
    instance is initialized. That would be nice if i could change name of TC from
    setup().

    --
    sdmitry -=- Dmitry V. Sabanin
    MuraveyLabs.


    Dmitry V. Sabanin Guest

  2. Similar Questions and Discussions

    1. #39804 [NEW]: Testcase 008.phpt is getting failed.
      From: shaamcom_83 at yahoo dot co dot in Operating system: Linux PHP version: 5.2.0 PHP Bug Type: CGI related Bug...
    2. Type on human face
      OS 9.2.2 PS 7 Will someone please point me in the direction of a tutorial that will inform me as to how I might superimpose type on a human face...
    3. debug testcase keyword
      I am working on a regexp engine, where I follow the test first paradigm. I want my regexp-engine to be compatible with Ruby's, therefore I share...
    4. Is there a way to print out the contents of a variable in human readable format?
      Is it possible to print out the contents of a variable in a human readable format? For instance like PHP's print_r() function? Thanks in...
    5. Idea for a better use of human intelligence
      Hello, About the tecnical aspect of my "Idea for a better use of human intelligence" I was told, that it could be realized in php....
  3. #2

    Default Re: TestCase human-readable name

    Dmitry V. Sabanin [mailto:sdmitry@lrn.ru] wrote:
    > I have a question about TestUnit. How can i set a human-readable name for
    my
    > TestCase? I see name argument for a new, but i don't know where class
    > instance is initialized. That would be nice if i could change name of TC
    from
    > setup().
    I'm having trouble understanding what it is you want to change the name of.
    In Test::Unit, what happens is that your TestCase class is initialized once
    for each test that it contains. So if you have a TestCase like this:

    class TC_Me < Test::Unit::TestCase
    def test_me
    end

    def test_me_too
    end
    end

    The framework will call the constructor of your TestCase once for each test:

    TC_Me.new(:test_me)
    TC_Me.new(:test_me_too)

    Thus, the TestCase is 'named' once for each test that it contains.

    I'm guessing that you're asking this question because you want to change the
    output somehow... I might be able to help more if I can get a better feel
    for what you're trying to accomplish.

    HTH,


    Nathaniel

    <:((><


    Nathaniel Talbott Guest

  4. #3

    Default Re: TestCase human-readable name

    On Friday 08 August 2003 22:21, Nathaniel Talbott wrote:
    > Dmitry V. Sabanin [mailto:sdmitry@lrn.ru] wrote:
    > > I have a question about TestUnit. How can i set a human-readable name for
    >
    > my
    >
    > > TestCase? I see name argument for a new, but i don't know where class
    > > instance is initialized. That would be nice if i could change name of TC
    >
    > from
    >
    > > setup().
    >
    > I'm having trouble understanding what it is you want to change the name of.
    > In Test::Unit, what happens is that your TestCase class is initialized once
    > for each test that it contains. So if you have a TestCase like this:
    >
    > class TC_Me < Test::Unit::TestCase
    > def test_me
    > end
    >
    > def test_me_too
    > end
    > end
    >
    > The framework will call the constructor of your TestCase once for each
    > test:
    >
    > TC_Me.new(:test_me)
    > TC_Me.new(:test_me_too)
    >
    > Thus, the TestCase is 'named' once for each test that it contains.
    >
    > I'm guessing that you're asking this question because you want to change
    > the output somehow... I might be able to help more if I can get a better
    > feel for what you're trying to accomplish.
    I want to do something similiar to, but for a test case:
    def self.suite
    suite = Test::Unit::TestSuite.new "Muravey News System Tests"
    end
    where output is:
    Loaded suite Muravey News System Tests
    Started
    FFF
    Finished in 0.008444 seconds.

    Now output for testcases is:
    1) Failure!!!
    test_get_news(TC_MNS_View_News) [./tests/test_view.rb:28]:

    I want TC_MNS_Views_News to be replaced with my own string, like in
    TestSuite. If it's not possible i will live with that :)
    > HTH,
    >
    >
    > Nathaniel
    >
    > <:((><
    --
    sdmitry -=- Dmitry V. Sabanin
    MuraveyLabs.


    Dmitry V. Sabanin Guest

  5. #4

    Default Re: TestCase human-readable name

    Dmitry V. Sabanin [mailto:sdmitry@lrn.ru] wrote:
    > I want to do something similiar to, but for a test case:
    > def self.suite
    > suite = Test::Unit::TestSuite.new "Muravey News System Tests"
    > end
    > where output is:
    > Loaded suite Muravey News System Tests
    > Started
    > FFF
    > Finished in 0.008444 seconds.
    >
    > Now output for testcases is:
    > 1) Failure!!!
    > test_get_news(TC_MNS_View_News) [./tests/test_view.rb:28]:
    >
    > I want TC_MNS_Views_News to be replaced with my own string, like in
    > TestSuite. If it's not possible i will live with that :)
    This (or some variant) will work:

    require 'test/unit'

    class Test::Unit::TestCase
    def name
    "#@method_name(#{self.class.fixture_name})"
    end
    end

    class TC_Me < Test::Unit::TestCase
    def self.fixture_name
    "It's all about ME!"
    end

    def test_me
    flunk
    end
    end

    Output:

    Loaded suite t
    Started
    F
    Finished in 0.02 seconds.

    1) Failure!!!
    test_me(It's all about ME!) [t.rb:15]:

    1 tests, 1 assertions, 1 failures, 0 errors

    I'm not sure I like this... the point of having the class name there is that
    it makes it easier to figure out where in the world the failure occurred.
    It's your code, though :-)

    HTH,


    Nathaniel

    <:((><


    Nathaniel Talbott Guest

  6. #5

    Default Re: TestCase human-readable name

    On Saturday 09 August 2003 00:06, Nathaniel Talbott wrote:
    > I'm not sure I like this... the point of having the class name there is
    > that it makes it easier to figure out where in the world the failure
    > occurred. It's your code, though :-)
    Thanks a lot Nataniel!
    Class name is good for searching where the failure is, but line number is more
    usefull for me (class name don't give me much information, as for example
    name of section where error happened do). But there is not much difference
    here..
    > HTH,
    >
    >
    > Nathaniel
    >
    > <:((><
    --
    sdmitry -=- Dmitry V. Sabanin
    MuraveyLabs.


    Dmitry V. Sabanin 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