running unit tests in graphical mode

Discussion in 'Ruby' started by Navya Amerineni, Jan 25, 2006.

  1. --0-2062298583-1138166088=:22788
    Content-Type: text/plain; charset=iso-8859-1
    Content-Transfer-Encoding: quoted-printable

    Hi,

    I have the following program written and when I run It comes up saying z=
    ero tests.
    what more should include in the code below for it to run in graphical mod=
    e.
    Please Help


    require 'test/unit/ui/tk/testrunner'
    class Roman
    MAX_ROMAN =3D 4999
    =20
    def initialize(value)
    if value <=3D 0 || value > MAX_ROMAN
    fail "Roman values must be > 0 and <=3D #{MAX_ROMAN}"
    end
    @value =3D value
    end
    FACTORS =3D [["m", 1000], ["cm", 900], ["d", 500], ["cd", 400],
    ["c", 100], ["xc", 90], ["l", 50], ["xl", 40],
    ["x", 10],["ix" ,9], ["v", 5], ["iv", 4],
    ["i", 1]]
    =20
    def to_s
    value =3D @value
    roman =3D "";
    for code, factor in FACTORS
    count, value =3D value.divmod(factor)
    roman << (code * count)
    end
    roman
    end
    end
    class TestRoman < Test::Unit::UI::Tk::TestRunner
    def test_simple
    assert_equal("i", Roman.new(1).to_s)
    assert_equal("ix", Roman.new(9).to_s)
    assert_equal("ii", Roman.new(2).to_s)
    assert_equal("iii", Roman.new(3).to_s)
    assert_equal("iv", Roman.new(4).to_s)
    end
    end


    Thanks,
    Navya.


    =09
    ---------------------------------
    Do you Yahoo!?
    With a free 1 GB, there's more in store with Yahoo! Mail.
    --0-2062298583-1138166088=:22788--
    Navya Amerineni, Jan 25, 2006
    #1
    1. Advertising

  2. Navya Amerineni

    Pit Capitain Guest

    Hi Navya,

    you have to change two lines in your code:

    > require 'test/unit/ui/tk/testrunner'


    Change the preceding line to:

    require 'test/unit'

    > class TestRoman < Test::Unit::UI::Tk::TestRunner


    Change that to:

    class TestRoman < Test::Unit::TestCase

    A TestRunner is the thing that is running all your tests, which should
    be subclasses of Test::Unit::TestCase. To find out how to use another
    TestRunner, run your script with the option -h:

    ruby <yourscript.rb> -h

    Regards,
    Pit
    Pit Capitain, Jan 25, 2006
    #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. Guest
    Replies:
    3
    Views:
    749
    Guest
    Feb 5, 2004
  2. Joe Van Dyk

    running unit tests in graphical mode

    Joe Van Dyk, Jun 29, 2005, in forum: Ruby
    Replies:
    9
    Views:
    154
    R. Mark Volkmann
    Jun 30, 2005
  3. Brett Schuchert
    Replies:
    6
    Views:
    118
    Brett Schuchert
    Apr 3, 2007
  4. Tim Golden

    Re: Running python's own unit tests?

    Tim Golden, Nov 14, 2013, in forum: Python
    Replies:
    0
    Views:
    67
    Tim Golden
    Nov 14, 2013
  5. Zachary Ware

    Re: Running python's own unit tests?

    Zachary Ware, Nov 14, 2013, in forum: Python
    Replies:
    0
    Views:
    77
    Zachary Ware
    Nov 14, 2013
Loading...

Share This Page