[Mono-list] Regression tests tutorial
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 =
- 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 =
- 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
Cactus Commerce Software Developer * D=E9veloppeur de =
eBusiness. All Business. email@example.com
From: Miguel de Icaza [mailto:firstname.lastname@example.org]=20
Sent: Monday, May 12, 2003 11:45 AM
Subject: [Mono-list] Regression tests tutorial
For all the brave new developers that have volunteered to write
NUnit tests for Mono, you will find a tutorial document in:
(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 email@example.com
Thanks to everyone that responded!
(Also, it would be nice if we got the NUnitGuidelines document in
the Mono Tutorial).
Mono-list maillist - Monofirstname.lastname@example.org