Robin Szemeti <[EMAIL PROTECTED]> writes:

> Rightio ...
> 
> since its a Tuesday and also a waning 3/4 moon its *New Methodology Day*
> and the random choice from Big Ted's bookcase was XP::Installed
> 
> to wit, testing of object based modules. Firstly what do people generally
> use for this? Test::Unit ?? or is there something more freindly out
> there?

Test::Unit *almost* does the right thing, but looking through the code
there are some horrible things being done (by someone who doesn't seem
to understand the reflection/introspection and dynamic features of
Perl), and the test suite it comes with doesn't seem to have
desperately good coverage of the various testing modules. Which is why
I'm working on it...

> secondly abstraction:
> 
> If I have , say a 'data' object that can store, retreive and list various
> data in a schema, good OO practice would suggest that I test the object
> without knowing whether it stores its data in a flatfile, a databse or
> DNA structure, what is important is that it can store, retreive and list
> the info ... but obviously I have to tell it to use (in this case) a test
> MySQL db to load and retreive info from .. which seems contradictory ..
> or is that the difference between unit tests and acceptance tests ...
> unit tests are allowed to test specific variants of modules (flatfile
> based, MySQL based etc) where as the acceptance tests just work with
> whatever module is loaded and treat it as a black box ...???
> 
> am I making any sense ? .. oh well ...

Why does the data object have to know how/if it's stored? Have a data
librarian object which is responsible for handling moving objects into
and out of storage. Then test the librarian to make sure that it can
retrieve stuff in the appropriate fashion, and do your data object
unit testing (possibly) without even having the librarian loaded up.
If you *do* find that you need to have the librarian loaded for some
of the data object's methods to work, think hard and see if you can't
find some way of removing that dependency. 

The difference between a Unit test and an Acceptance test is that the
unit test tries its damndest to test the behaviour of the class and
its methods etc independently of everything else in the system.
An Acceptance test then tests that the entire system behaves as it
should for a given task.

-- 
Piers

Reply via email to