Re: Unit testing framework suggestions?
Re: Unit testing framework suggestions?
- Subject: Re: Unit testing framework suggestions?
- From: Marco Scheurer <email@hidden>
- Date: Fri, 24 Sep 2004 04:56:31 +0200
On Sep 23, 2004, at 22:51, M. Uli Kusterer wrote:
E.g. UnitKit keeps separate "test objects", which I find kinda odd.
I'm wondering why one shouldn't put the tests in the object in need of
the testing instead... things like that.
Most implementations of testing kits implements tests in a subclass of
TestCase.
One reason is that tests can have their own state and ivars, and it
wouldn't be a good idea to mix this with the class you want to test.
Another is that tests are written from the perspective of a user of the
class rather than as "internal" tests. A good practice is to write the
tests before you write the tested code. If you do so, your tests can be
seen as a formal specification of the code to be written.
Another is that a lot of stuff is usually done in the TestCase class,
so that writing a test is as simple as writing a single method in a
subclass of TestCase.
All the xUnit packages are more or less derived from the original
Smalltalk "SUnit". The seminal article is by Kent Beck, and can be
found at http://www.armaties.com/testfram.htm . So there is also an
historical reason for doing it in subclasses of Testcase.
However, this can be done differently. For instance, Marcel Weiher
advocates putting the tests in a category of the tested class.
Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden