List tests with test/unit

Discussion in 'Ruby' started by Matt Berney, Jul 23, 2007.

  1. Matt Berney

    Matt Berney Guest

    Test::Unit is quite useful. I have a test class TC_BasicAcceptanceTest
    with the following tests:

    test_001_firstTest
    test_002_secondTest
    test_003_thirdTest

    ...

    You get the picture.

    Now, the ruby bat.rb -n <test name> is really useful. It allows the
    execution of a single test within the test case. For running tests (and
    debugging) on the command line, it would be useful to list all the tests
    in the suite. Then, one could use the -n flag to run the one of
    interest.

    For example:

    % ruby bat\bat.rb -l

    TC_BasicAcceptanceTest
    test_001_firstTest
    test_002_secondTest
    test_003_thirdTest

    % ruby bat\bat.rb -n test_002_secondTest

    Now the question...
    If one wanted to modify the autorunner.rb, how would one iterate through
    the tests in the test case? This code only lists the TC name. How does
    one list the individual test cases?

    o.on('-l', '--list', 'List the tests to run.'){
    @collector[self].tests.each { |tc| puts "#{tc.name}" }
    exit
    }
    --
    Posted via http://www.ruby-forum.com/.
     
    Matt Berney, Jul 23, 2007
    #1
    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. Ben Finney

    Iterating over test data in unit tests

    Ben Finney, Dec 6, 2005, in forum: Python
    Replies:
    6
    Views:
    286
    Scott David Daniels
    Dec 6, 2005
  2. Alexey Verkhovsky

    Parameterized tests with test/unit

    Alexey Verkhovsky, Jul 24, 2004, in forum: Ruby
    Replies:
    8
    Views:
    333
    Alexey Verkhovsky
    Jul 30, 2004
  3. Simon Strandgaard
    Replies:
    14
    Views:
    185
    Nathaniel Talbott
    Aug 16, 2004
  4. Raphael Bauduin
    Replies:
    6
    Views:
    101
    Nathaniel Talbott
    Feb 2, 2005
  5. timr
    Replies:
    2
    Views:
    167
Loading...

Share This Page