anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00017
Re: PHPUnit testsuites
Hi Sander (and others),
2009-04-02 klockan 01:04 skrev Sander van Schouwenburg:
> After watching the database.new testcases and reading the PHPUnit
> documentation, I was wondering if sqlite (and postgresql) tests aren't
> too high level. The PHPUnit documentation suggests keeping tests as low
> level as possible, preferably on a single-method level. The sqlite tests
> however go as high as AnewtDatabase and SQLTemplate. Shouldn't those
> things be tested in their own testsuite?
Well, the database unit I've added recently were very high level for various
reasons:
- I wanted to get it (sort-of) working quickly
- I ported all tests from the existing test files
- I think it makes much sense for the database module to have method level
tests, since it's all about hooking all (oten trivial) pieces up. One test
(or test method) that does a sequence of things (e.g. prepare a query,
execute it with various values, obtain result sets and check those for
validity) will not succeed if ANY part of it fails. In other words: if
there is anything wrong, the test will indicate that something is wrong,
but it won't tell you directly which (sub)part caused the failure; in
practice the error and traceback often tells you were to look though.
> Also you should watch out with inheritance. A base class can implement a
> method which works fine, and a subclass might *not* overload that
> method, it should still probably still be tested. That, or the base
> method should be tested well enough to account for variations in
> subclasses.
Good point, but I think it's not as simple as that. Many base classes are
abstract and often miss critical functionality, and cannot be instanted
directly, hence they cannot be tested directly either. Examples of this
include AnewtDatabaseConnection (misses the essential DB connectivity code)
and AnewtFormControl (misses rendering code). Only the (concrete) subclass
instances can be tested.
Thanks for your work.
— Wouter
Attachment:
signature.asc
Description: Digital signature
Follow ups
References