httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Benson <>
Subject Re: t/modules/rewrite tweaking
Date Thu, 09 Aug 2001 12:05:22 GMT

On Thu, 9 Aug 2001, Stas Bekman wrote:

> On Thu, 9 Aug 2001, Gary Benson wrote:
> > On Thu, 9 Aug 2001, Stas Bekman wrote:
> >
> > > Some methods of extreme programming suggest writing tests even before
> > > the code have been written
> >
> > I tried this once, for the lexical parser in a desktop calculator program
> > I wrote. It is a really liberating experience, and leads to greater
> > experimentation.
> the only problem is that usually to write some more advanced tests, you
> actually need to have some working code, since you have to debug the test
> itself.
> So I think that if you have this approach you write only the descriptions
> of the tests. Is that how you've done this?

The testing engine was fairly simple: it created an instance of the lexer
class, ran the test input through it and printed out a representation of
the list of tokens that the parser returned.

The tests were much more simple to construct that those in perl-framework,
but mine were unit tests rather than functional tests. The distinction is
important -- anyone who doesn't know the difference should skim through and

I've attached the array of tests that I used, so that you can get an
idea of what I mean (but feel free to ignore it =))

What generally happens is that the tests evolve with the code. I wrote a
very basic lexer and wrote some tests for it. I added some more tokens to
the lexer, I added tests for those tokens.

The beauty of it all was that a few days later I realised that I had a
problem with the lexer -- the state machine that drove it couldn't cope
with something I wanted to do. After changing the state machine, the
original stuff was processed in a totally different way but the end result
should have been the same. The tester was a phenomenal help during the

Once all the tests worked, I _knew_ that:

 1. What I wanted the lexer to do was completely covered by the tests
 2. The tests worked

and therefore:

 3. The lexer did exactly what I wanted it to do.

What I was testing was a very small piece of code, so it was simple for me
to acheive this kind of certainty. To do the same for Apache will not be
a trivial task. It will be better if we can reach the stage where people
write tests for the modules as they write the modules, but we have some
catching up to do first.


[ Gary Benson, Red Hat Europe ][ ][ GnuPG 60E8793A ]

View raw message