[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

test/unit non-exit on failure

Belorion

2/17/2005 9:41:00 PM

I sarted using test/unit today, and have a quick question that wasn't
answered by a quick google:

Right now (ruby 1.8.1) if one of my assertions fail, my test termiates
early to report the error. Is it possible to have it complete *all*
tests, and then give a report at the end? I have some bugs whose
nature may be better elucidated if I can see the results of the other
tests.

Obviously, I can go in and comment out the failed tests so as to
ensure the others are reached, but this seems like the hard way...

Thanks,
Matt


5 Answers

Dick Davies

2/17/2005 9:42:00 PM

0

* Belorion <belorion@gmail.com> [0241 21:41]:
> I sarted using test/unit today, and have a quick question that wasn't
> answered by a quick google:
>
> Right now (ruby 1.8.1) if one of my assertions fail, my test termiates
> early to report the error. Is it possible to have it complete *all*
> tests, and then give a report at the end? I have some bugs whose
> nature may be better elucidated if I can see the results of the other
> tests.
>
> Obviously, I can go in and comment out the failed tests so as to
> ensure the others are reached, but this seems like the hard way...

Can you just split the test into smaller ones?

--
'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


Belorion

2/17/2005 10:28:00 PM

0

> Can you just split the test into smaller ones?

Though that is certainly a viable solution, it is not ideal. For
example, I have one test run which attempts 10 assertions on a single
method with varying parameter values. 5 of these assertions failed
(yes, my method obviously has some issues :P ). This meant running
the test 5 times, and after each run I had to go comment out the known
failed assertions so I could find out what else did or did not work.

Or, I could have written out 10 different smaller tests ... but to me
that seems to break the logic of wanting to run like assertions
together in the same test ... after all, they were all on the same
method and testing the same logic. If, later down the line I want to
run these tests again, but not *all* of the tests in my suite, I would
have to pass each test_name at the command line. This seems to make
unit testing more complicated than it should be (which I admit is
still nicer than unit testing in any other language I've used). Is
asking test/unit to run all assertions in a test regardless of outcome
not possible then?


Nathaniel Talbott

2/18/2005 1:16:00 AM

0

On Feb 17, 2005, at 17:27, Belorion wrote:

> Is asking test/unit to run all assertions in a test regardless of
> outcome
> not possible then?

No, it is not possible. It's not even an easy hack on the framework.
I've considered it, particularly for functional/acceptance testing, but
haven't gotten around to deciding if it's a good idea or not.


> I could have written out 10 different smaller tests ... but to me
> that seems to break the logic of wanting to run like assertions
> together in the same test ... after all, they were all on the same
> method and testing the same logic. If, later down the line I want to
> run these tests again, but not *all* of the tests in my suite, I would
> have to pass each test_name at the command line. This seems to make
> unit testing more complicated than it should be (which I admit is
> still nicer than unit testing in any other language I've used).

Note that if you gave these related tests a similar name, you could run
them all in one fell swoop from the command line using a regex. Also,
if they're sufficiently similar, you could even generate the test
methods at runtime, which might reduce any redundancy between them.

HTH,


Nathaniel

<:((><



Belorion

2/18/2005 3:05:00 PM

0

> Note that if you gave these related tests a similar name, you could run
> them all in one fell swoop from the command line using a regex. Also,
> if they're sufficiently similar, you could even generate the test
> methods at runtime, which might reduce any redundancy between them.

Using a regex hadn't occurred to me. And thanks for the response (I
think it is wonderful that one can get such prompt responses from so
many of the library devs here on ruby-talk!)

Matt


Eric Hodel

2/18/2005 7:05:00 PM

0

On 17 Feb 2005, at 17:15, Nathaniel Talbott wrote:

> On Feb 17, 2005, at 17:27, Belorion wrote:
>
>> I could have written out 10 different smaller tests ... but to me
>> that seems to break the logic of wanting to run like assertions
>> together in the same test ... after all, they were all on the same
>> method and testing the same logic. If, later down the line I want to
>> run these tests again, but not *all* of the tests in my suite, I would
>> have to pass each test_name at the command line. This seems to make
>> unit testing more complicated than it should be (which I admit is
>> still nicer than unit testing in any other language I've used).
>
> Note that if you gave these related tests a similar name, you could
> run them all in one fell swoop from the command line using a regex.
> Also, if they're sufficiently similar, you could even generate the
> test methods at runtime, which might reduce any redundancy between
> them.

ZenTest can generate test stubs for you, or generate method stubs for
your tests.

http://www.zenspider.com/ZSS/Product...

--
Eric Hodel - drbrain@segment7.net - http://se...
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04