test/unit non-exit on failure

B

Belorion

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
 
B

Belorion

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?
 
N

Nathaniel Talbott

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

<:((><
 
B

Belorion

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
 
E

Eric Hodel

--Apple-Mail-8--550201421
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed

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/Products/ZenTest/

--
Eric Hodel - (e-mail address removed) - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

--Apple-Mail-8--550201421
content-type: application/pgp-signature; x-mac-type=70674453;
name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFCFjxhMypVHHlsnwQRApxLAJ9a02WIJ5bXesFlbNiSfLUlHCGrbgCfX1BZ
cEUyWEVohSUWmAZhPxpWk04=
=zCOG
-----END PGP SIGNATURE-----

--Apple-Mail-8--550201421--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top