Marcin,

I don't have a link to good unit tests right now, but I do have some
suggestions that unit tests should follow...

* A good unit test (fixture) should set up its required environment
before running its tests, and tear down the environment afterwards.
* A good unit test tests *only* the code it is trying to test.  That
is, it won't fail because of some other code.

Unit tests are particularly difficult to write when external resources
are involved, because of these (suggested) requirements.  In
particular, unit tests for subversion tasks mustn't assume the
existence of any repository, at any location.  Someone may be trying
to build (and test) NAnt on a machine with no internet connection, and
no local subversion server, and this shouldn't fail due to unit tests.

One way to get around this is to test for the suitability of running
the tests and fail in the setup method if the required environment for
the tests is not found.  This will mark the tests as "not run" instead
of "failed", and so won't cause the build to fail.

The VC++ tests deal with this in a similar, but slightly different way:
http://cvs.sourceforge.net/viewcvs.py/nant/nant/tests/NAnt.VisualCpp/Tasks/ClTaskTest.cs?rev=1.8&view=markup
(or http://makeashorterlink.com/?E2CF526BA )


-- 
Troy


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
nant-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to