in reply to Automatic generation of tests
Test cases (more specially test suites) need to be written in actual code, if they must be documented, document above the test case using POD.
Why? Because you need to run them. Use of any language that is not Perl to write the tests will result in your tests being less flexible than Perl, meaning you are probably going to drop some corner cases through use of some meta language. The group example you gave was rather simple to test, but many things will be much harder. Suppose, for instance, that you have a complex simulation, tons of equations, or (dunno) some sort of ray-tracer. Can you write tests for that in some alien syntax? Probably not.
I just looked at Test::Inline, and (to be fair) the syntax is a little ugly to me. Why? The use of pod to enter and exit code reminds me of C code that is riddled with #ifdef's ... it's very hard to grok the execution path from looking at the source. Further, compilation of one form doesn't ensure the other form is valid code. It's essentially #ifdef'd using POD!
My suggestion ... write the test cases in Perl, and keep them seperate from your main code (in a seperate file if needed). This way, you won't be coding tests that pass your code, since you'll have to think more about your tests. Some programming courses teach "write tests first". Well, I seldom do this (bad flyingmoose!) but the concept is that, this way, you test without preconceptions.
So in conclusion, I think this model would be A) look a lot like ifdef'd code (hard to read) and B) be full of preconceptions since your test cases would be above your code. Also, it would be yet-another-syntax to remember, and, after all, we know Perl. My vote -- keep your tests as code, just document them.
Anyhow, just my fifty three cents. I'm open to debate on this, I just want to play devil's advocate a bit...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Automatic generation of tests
by DrHyde (Prior) on Feb 23, 2004 at 14:40 UTC | |
by adrianh (Chancellor) on Feb 23, 2004 at 15:33 UTC | |
by DrHyde (Prior) on Feb 24, 2004 at 09:44 UTC | |
by adrianh (Chancellor) on Feb 25, 2004 at 11:54 UTC | |
by Jenda (Abbot) on Feb 25, 2004 at 14:56 UTC | |
| |
|
Re: Re: Automatic generation of tests
by Anonymous Monk on Feb 23, 2004 at 15:03 UTC | |
by adrianh (Chancellor) on Feb 23, 2004 at 15:23 UTC | |
by Anonymous Monk on Feb 23, 2004 at 18:41 UTC | |
by adrianh (Chancellor) on Mar 05, 2004 at 15:35 UTC | |
by flyingmoose (Priest) on Feb 23, 2004 at 17:12 UTC | |
by adrianh (Chancellor) on Feb 23, 2004 at 17:21 UTC | |
by Anonymous Monk on Feb 23, 2004 at 19:10 UTC | |
by adrianh (Chancellor) on Mar 05, 2004 at 15:58 UTC | |
by Anonymous Monk on Mar 09, 2004 at 06:43 UTC | |
|