[Mono-list] Regression tests tutorial

Philippe Lavoie philippe.lavoie@cactus.ca
Mon, 12 May 2003 13:13:44 -0400


Perhaps you can write a little section that describes what is a unit =
test and how best to use it. My suggestion follows, please reformat in =
proper English if you want to use it.

Unit tests are small functional tests. They allow you to write a black =
box or a white box testing harness for your library or application. =
There are different ways to write tests and each has merits and =
drawbacks. Here are some guidelines:

 - Test a requirement and not an implementation, i.e. focus on the =
functionality required.

 - Avoid testing a function's output unless the function corresponds to =
a requirement or a sub-requirement. You should leave enough room for a =
developper to refactor his code. Actually, you can do as much white box =
testing as you want, however the test should be marked as so since =
refactoring the code implies dropping those tests: they weren't testing =
a requiremenet but testing how one way of implementing it was done.

 - Don't write meta-tests. For example, writing a function which tests =
all the exceptions that can be thrown. Instead test each exception on a =
different function. When looking at the Nunit-Gui test list, it should =
be clear what is tested inside the test harness for a particular class. =
It is better to have 40 precise methods than 3 general. For example: =
testOverflowException, testEmptyExcpetion, =
testInvalidCharactersException could be used to test the serialization =
of a number instead of testExcpetions.

 - Write small tests. Each test should take very little time to execute. =
The idea is to run the test suite as often as possible (i.e. after each =
succesfull compile for example) therefore, wait time should be =
minimized.

 - Write scenario based tests. Requirements are always part of a =
scenario, adding the context in which the functions are used help make =
sure integration works well. Those tests could be in a different test =
library if they  take too much time, i.e. testing the code against 100 =
clients for example.=20
 =20

Philippe Lavoie
=20
   Cactus Commerce           Software Developer  *  D=E9veloppeur de =
logiciels
eBusiness. All Business.          philippe.lavoie@cactuscommerce.com
=20


-----Original Message-----
From: Miguel de Icaza [mailto:miguel@ximian.com]=20
Sent: Monday, May 12, 2003 11:45 AM
To: mono-list@ximian.com
Cc: mono-docs-list@ximian.com
Subject: [Mono-list] Regression tests tutorial

Hello!

   For all the brave new developers that have volunteered to write
NUnit tests for Mono, you will find a tutorial document in:

	mcs/class/doc/NUnitGuidelines

   (This is part of the "mcs" package).

   Get your Mono installed;  Then get the sources for MCS from AnonCVS
or from the daily snapshots, and you can start coding.  Send your tests
to the mono-devel-list@ximian.com

   Thanks to everyone that responded!

   (Also, it would be nice if we got the NUnitGuidelines document in
the Mono Tutorial).

Miguel
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list