unit/test : I don't want to automatically run all tests

Discussion in 'Ruby' started by Raphael Bauduin, Feb 1, 2005.

  1. Hi,

    I'm writing some unit tests and the plan is to let them run each night, and producing a little
    web page summarizing the results.

    I've written my tests, put them in a suite, and want to run them, but collect the results
    to build the web page afterwards. I use this code:

    result = Test::Unit::TestResult.new()
    MyTestClass.suite.run(result) {|s, name| puts "Status=#{s} and name = #{name}"}

    This runs absolutely fin, but test/unit then automatically starts to run all tests define in the file.
    This is a feature of test/unit (as noted at http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/index.html and
    at http://www.rubygarden.org/ruby?UsingTestUnit), but I really don't need it here. Can I turn this behaviour off?

    Thanks.

    Raph
    Raphael Bauduin, Feb 1, 2005
    #1
    1. Advertising

  2. When you terminate your test runner with exit!, test/unit will not have
    a chance to run tests on its own.

    Gennady.

    Raphael Bauduin wrote:
    > Hi,
    >
    > I'm writing some unit tests and the plan is to let them run each night,
    > and producing a little
    > web page summarizing the results.
    >
    > I've written my tests, put them in a suite, and want to run them, but
    > collect the results to build the web page afterwards. I use this code:
    >
    > result = Test::Unit::TestResult.new()
    > MyTestClass.suite.run(result) {|s, name| puts "Status=#{s} and name =
    > #{name}"}
    >
    > This runs absolutely fin, but test/unit then automatically starts to run
    > all tests define in the file.
    > This is a feature of test/unit (as noted at
    > http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/index.html and
    > at http://www.rubygarden.org/ruby?UsingTestUnit), but I really don't
    > need it here. Can I turn this behaviour off?
    >
    > Thanks.
    >
    > Raph
    >
    Gennady Bystritksy, Feb 1, 2005
    #2
    1. Advertising

  3. Gennady Bystritksy wrote:
    > When you terminate your test runner with exit!, test/unit will not have
    > a chance to run tests on its own.
    >


    yep, that's what I've found as solution, but I thought there was a better way :)

    Raph

    > Gennady.
    >
    > Raphael Bauduin wrote:
    >
    >> Hi,
    >>
    >> I'm writing some unit tests and the plan is to let them run each
    >> night, and producing a little
    >> web page summarizing the results.
    >>
    >> I've written my tests, put them in a suite, and want to run them, but
    >> collect the results to build the web page afterwards. I use this code:
    >>
    >> result = Test::Unit::TestResult.new()
    >> MyTestClass.suite.run(result) {|s, name| puts "Status=#{s} and name =
    >> #{name}"}
    >>
    >> This runs absolutely fin, but test/unit then automatically starts to
    >> run all tests define in the file.
    >> This is a feature of test/unit (as noted at
    >> http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/index.html and
    >> at http://www.rubygarden.org/ruby?UsingTestUnit), but I really don't
    >> need it here. Can I turn this behaviour off?
    >>
    >> Thanks.
    >>
    >> Raph
    >>

    >
    >
    >
    Raphael Bauduin, Feb 1, 2005
    #3
  4. Raphael Bauduin

    Dick Davies Guest

    * Raphael Bauduin <> [0251 13:51]:
    > Hi,
    >
    > I'm writing some unit tests and the plan is to let them run each night, and
    > producing a little
    > web page summarizing the results.
    >
    > I've written my tests, put them in a suite, and want to run them, but
    > collect the results to build the web page afterwards. I use this code:
    >
    > result = Test::Unit::TestResult.new()
    > MyTestClass.suite.run(result) {|s, name| puts "Status=#{s} and name =
    > #{name}"}


    Look at the (source of ) TestTask in rake (http://rake.rubyforge.org), that provides a
    means of running a named test rather than the lot.

    --
    'The old 'give em a Linux box and they think they're Jean-Luc Picard' syndrome.'
    -- Pete Bentley
    Rasputin :: Jack of All Trades - Master of Nuns
    Dick Davies, Feb 1, 2005
    #4
  5. Raphael Bauduin

    Alan Chen Guest

    If you define test sets in different files, yet another way is
    controlling what tests are defined via selective requires.
    Alan Chen, Feb 1, 2005
    #5
  6. Raphael Bauduin

    Alan Chen Guest

    If you define test sets in different files, yet another way is
    controlling what tests are defined via selective requires.
    Alan Chen, Feb 1, 2005
    #6
  7. On Feb 1, 2005, at 08:50, Raphael Bauduin wrote:

    > This runs absolutely fin, but test/unit then automatically starts to
    > run all tests define in the file.
    > This is a feature of test/unit (as noted at
    > http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/index.html and
    > at http://www.rubygarden.org/ruby?UsingTestUnit), but I really don't
    > need it here. Can I turn this behaviour off?


    Adding this should do it:

    Test::Unit.run = true

    That's what the built-in runners do.

    HTH,


    Nathaniel
    Terralien, Inc.

    <:((><
    Nathaniel Talbott, Feb 2, 2005
    #7
    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. Bill David
    Replies:
    2
    Views:
    260
    Arne Vajhøj
    Jun 18, 2008
  2. Sean O'Dell

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

    Sean O'Dell, Sep 18, 2003, in forum: Ruby
    Replies:
    1
    Views:
    103
    Sean O'Dell
    Sep 18, 2003
  3. Simon Strandgaard
    Replies:
    14
    Views:
    173
    Nathaniel Talbott
    Aug 16, 2004
  4. Brett Schuchert
    Replies:
    6
    Views:
    120
    Brett Schuchert
    Apr 3, 2007
  5. timr
    Replies:
    2
    Views:
    151
Loading...

Share This Page