[dokuwiki] Re: DokuWiki Unittesting

  • From: Harry Fuecks <hfuecks@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 19 Oct 2005 01:31:49 +0200

OK - will do my best.

The main point of unit testing is to have code to test your code. My
sound odd if you haven't run into this before. I wrote a gentle intro
to the concept a long time ago here:
http://www.phppatterns.com/docs/develop/unit_testing_in_php

The real benefit is it helps you trust your code (or someone elses)
when it starts to get complex (and perhaps you've forgotten what you
did). If you make changes later, the tests help you verify quickly
that nothing is broken. Another way to look at it - if everyone who
submits a bug provides a test which illustrates the problem, no
Dokuwiki bug will ever get re-introduced by a later change (well
that's the theory ;-))

For Dokuwiki one particular issue is going be testing functions which
call other functions - it's worth reading about "mock objects" to
understand this problem -
http://www.lastcraft.com/mock_objects_documentation.php.

There I think the APD extension can help -
http://wiki.splitbrain.org/php:apd - it allows you to rename functions
at runtime, allowing you to replace a function with your own safe /
predictable version for testing. I'll try to provide some examples
here soon - should have done so sooner - have been distracted by
getting http://www.phppatterns.com back online with Dokuwiki (woohoo!)
plus a hard disk that's failing.

Anyway - unit testing is difficult to explain in brief so best thing
is to read up - SimpleTest has excellent documentation / tutorials -
have linked to them at http://wiki.splitbrain.org/wiki:unittesting

On 10/19/05, Andreas Gohr <andi@xxxxxxxxxxxxxx> wrote:
> Hi all!
>
> Harry Fuecks suggested to use Unit-Testing for DokuWiki and after some
> thought I agreed with him. He provided a framework for easy test writing
> and I already added a few tests.
>
> Unit testing allows us to automatically test the behavior of singular
> DokuWiki parts. I think Harry can explain the why of testing much better
> (Harry could you give a short intro to the list?)...
>
> Fact is it is useful and will help to make DokuWiki much better and
> safer (eg. it can avoid things like the Security Bug discovered today).
>
> But to make the whole testing thing really useful we need much more
> tests. Harry wrote a little introduction on how to write tests for
> DokuWiki at http://wiki.splitbrain.org/wiki:unittesting - everyone
> contributing to DokuWiki should read it. People who want to help: please
> write tests.
>
> Anyone who submits bugs and bugfixes: add a test which's failing
> demonstrates the bug. Jan: I got your patch today - would be great if
> you could write the according test as well.
>
> I'm thinking about offering a small bounty for test writing (from
> donations I got over the last months)... something along a Dollar per
> tested function or something... write a few tests and I buy you
> a beer - nothing official yet ;-) I'd love to get your thoughts on this.
>
> Andi
>
>
>
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: