[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Raphael Bauduin

2/1/2005 1:48:00 PM

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/... and
at http://www.rubygarden.org/ruby?Usi...), but I really don't need it here. Can I turn this behaviour off?

Thanks.

Raph
6 Answers

Gennady

2/1/2005 3:45:00 PM

0

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/... and
> at http://www.rubygarden.org/ruby?Usi...), but I really don't
> need it here. Can I turn this behaviour off?
>
> Thanks.
>
> Raph
>



Raphael Bauduin

2/1/2005 4:19:00 PM

0

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/... and
>> at http://www.rubygarden.org/ruby?Usi...), but I really don't
>> need it here. Can I turn this behaviour off?
>>
>> Thanks.
>>
>> Raph
>>
>
>
>

Dick Davies

2/1/2005 11:16:00 PM

0

* Raphael Bauduin <raphael.bauduin@be.easynet.net> [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.rub...), 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


Alan Chen

2/1/2005 11:58:00 PM

0

If you define test sets in different files, yet another way is
controlling what tests are defined via selective requires.

Alan Chen

2/1/2005 11:58:00 PM

0

If you define test sets in different files, yet another way is
controlling what tests are defined via selective requires.

Nathaniel Talbott

2/2/2005 1:06:00 PM

0

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/... and
> at http://www.rubygarden.org/ruby?Usi...), 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.

<:((><