On 9/19/06, David Cantrell <[EMAIL PROTECTED]> wrote:
Adrian Howard wrote:
> Yeah - it's something I've noticed over the last year or so. I'm
> talking to people less about "you should write tests", and much more
> about "you should write /good/ tests".
What do people think are *good* tests?
My modules mostly have *comprehensive* tests, but that doesn't make them
good. In particular, my tests are largely uncommented, depend on
previous tests working, and are generally not laid out particularly
clearly. So my attempt to make my tests good will mostly consist of
applying the same coding standards to the test suites as I do to the
rest of the code.
Any tips on what - other than comprehensiveness, clarity and
maintainability - I should aim for specifically in test suites would be
greatly appreciated.
I think that an important tip for producing good tests is to consider
carefully that you haven't established implicit dependencies on a
specific operating environment in your tests.
So for instance if you have a routine that you expect to return a
specific path consider carefully how you can insulate your test from
platform specific representations of the path. Hardcoding it as
"/foo/bar/baz" is going to cause problems on many platforms, Win32,
Mac and VMS being the most obvious.
Examples of this type of stuff abound, as David Golden said earlier.
cheers,
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"