AW: Tests were are you?
Roel Wuyts
Roel.Wuyts at ulb.ac.be
Tue Nov 4 08:36:46 UTC 2003
For me it is hard for several reasons (depending on when you write the
test (e.g. in which part of the development cycle)):
1-test first, before implementing new stuff: So the problem is that you
are writing tests for something that you do not have already. There the
problem is that you are actually pinning down requirements for a
problem or a domain that you normally not really know yet. This is not
a real problem, but it is hard. I have nothing against it (you have to
do it sooner or later, and doing it sooner in the XP way poses less
risks).
2-writing tests after writing code: Then you are writing tests for
documentation purposes (kind of). This is hard because you want to
cover the implementation you have, so there is lots of work to do, and
you want to make sure that all your invariants that you implemented are
covered. Because you did not start by writing tests, this is a lot of
work and can become quite tricky. Sometimes you have to change your
implementation in order to be able to write tests (sometimes certain
accessors are needed, singleton patterns have to be broken up to add a
second instance for testin purposes, ...).
3-writing tests for unknown code: Before reengineering it is typically
good to write tests so that you know that you did not brake (too much)
when changing unknown things. So this is the problem as in (2) except
that here you do not even know the system, its invariants, ... So it
gets hard. Of course, reengineering is hard anyway...
4- enforcing application rules: Recently I began coding some meta-tests
(and | start to see them in other places as well): tests that express
patterns that code should stick to. For example, all subclasses of a
certain class have to override a class method, so I wrote a test to
check this. Or you can write a test that checks that for every class in
your system there is a corresponding test class (called
NameOfClassTests), that tests all methods). Or ... or ... or ... That
can be hard because you are writing rules to express your architecture,
making it explicit and testable.
On Tuesday, Nov 4, 2003, at 08:59 Europe/Zurich, Hannes Hirzel wrote:
> Ingo Hohmann wrote:
>
>> ducasse wrote:
>>> I agree. I spent more time writing tests for serious stuff than
>>> coding.
>>> Still my point was how can we can more apparent tests so that the
>>> community gets this point and can learn.
>>>
>>> Stef
>>>
>>> On Mercredi, oct 15, 2003, at 10:45 Europe/Zurich,
>>> Torsten.Bergmann at phaidros.com wrote:
>>>
>>>>
>>>> Writing good tests is much harder than writing good code!
>
>
> Interesting remark. This might be an explanation why the number of
> test cases Marcus Denker is collecting grows slowly but nonetheless it
> has
> been growing.
>
> Please tell me why you think that writing good test cases is hard?
>
>
> Hannes
>
>
>
Roel Wuyts
DeComp
roel.wuyts at ulb.ac.be Université Libre de
Bruxelles
http://homepages.ulb.ac.be/~rowuyts/
Belgique
Board Member of the European Smalltalk User Group: www.esug.org
More information about the Squeak-dev
mailing list
|