in reply to Re^3: Need advice on test output
in thread Need advice on test output
If you know that the test failed on line 2, that doesn't help you much.1: for my $key ( sort keys %tests ) { 2: is( $tests{$key}, $wooby{$key} ); 3: }
xoxo,
Andy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Need advice on test output
by BrowserUk (Patriarch) on Jan 06, 2007 at 01:13 UTC | |
File and line number makes no sense in the context of a failed test. Oh contrare. I'd at least have a starting point, even in this somewhat contrived example. In more normal cases, about 95% of those test scripts I've looked at, that consist of long linear lists of unnumbered ok()s and nok()s, having the line number of the failing test would save me from have to to play that most rediculous of games--count the tests. Are they numbered from zero or one? Does a TODO count or not? Do tests that exists inside runtime conditional if blocks count if the runtime condition fails? If no, how can I know whether that runtime condition was true of false? Etc. Of course, in this case I'd need other information too. But then in this case, the test number would be of no direct benefit either. In this case I'd have to modify the .t file to print out a sorted list of the keys to %tests at runtime, as there would be no other way to work out which test related to test N. Oh damn! But then tracing stuff out from with in a test script is a no-no, because the test tools usurp STDOUT and STDERR for their own purposes, taking away the single most useful, and most used, debugging facility known to programmer kind: print. And there you have it, todays number one reason I do not use these artificial, overengineered, maniacally OO test tools. They make debugging and tracing the test script 10 times harder than doing so for the scripts they are meant to test. They are an unbelievably blunt instrument, who's basic purpose is to display and count the numbers of boolean yeses and nos. To do this simple function And all of this so as to produce a bunch of 'pretty pictures and statistics' that I have no use for and have to use yet another layer (the test harness) to sift and filter to produce the only statistic I am interested in. What failed and where?For all the world this reminds me of those food ads and packaging that proclaim to world; "Product X is 95% fat free!". Ug. You mean that 5% of that crap is fat? To date, the best testing tool I've seen available is Smart::Comments. It's require, assert, ensure, insist, check, confirm, & verify methods are amazingly simple, amazingly powerful. Smart::Comments is the single, most useful, and most underrated module that theDamian (and possibly anyone) has yet posted to CPAN. I recognised the usefulness of the concept long ago when I came across Devel::StealthDebug, which may or may not have been the inspiration for Smart::Comments. In use, the former proved to be somewhat flaky, but theDamian has worked his usual magic with the concept (whether it was the inspiration for it or not), and come up with a real, and as yet unrecognised, winner. To achieve the perfect test harness, Why haven't I written it yet? Because I keep hoping that Of course, a few additional modules wouldn't go amiss. Smart::Comments::DeepCompare, Smart::Comments::LieToTheCaller and few others, but mostly it's all right there. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by ikegami (Patriarch) on Jan 06, 2007 at 06:46 UTC | |
Don't need a patch for this item. You can use if to achieve this.
Also, you could omit the use Smart::Comments and do -M.
However, the effect is shallow when using -M. Only the file loaded directly is affected. To test a module, you'd have to execute it as a script.
| [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Jan 06, 2007 at 08:07 UTC | |
Thanks, I like that. I'd still like the ability to switch between a 'Say nothing for passes but stop at the first assert failure' development mode and a 'Report everything, passes and failures, but don't stop' run-a-user-testcase mode; also the ability to adjust the Smartness level; via the command line or environment. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by petdance (Parson) on Jan 06, 2007 at 06:20 UTC | |
That's why you use comments on your tests, to describe what you're testing, and to make it easy to track down later. If you're getting bare ok 1\nok2\nok3 it's your own fault.
xoxo, | [reply] |
by BrowserUk (Patriarch) on Jan 06, 2007 at 07:32 UTC | |
But don't you see the dichotomy here? Because the test tools don't capture the line numbers, I have to add comments to allow me to get back to the line numbers. Not only does that create extra work, thinking up appropriate comments; typing them etc. It also create a bunch of knock on problems. For example, And remember, either way, all of this only gets me back to the place in the test script where the test failed. I've still got to get from there back to the code that it tests. And that could be literally anywhere. If the test that tests the code is in the same file and in rough proximity to the code being tested; and the failing test output incorporates the filename and line number; then my simple editor macro can take me straight there in one jump. There is simply no way to do this with the current system. The best you can do is see what apis are being called in the failing test and then grep all the source files and hope you turn up a likely looking candidate. This bad enough in a moderately complex suite of your own writing, but backing tracking in a complex test suite for code you didn't write, to the failing code is nigh impossible. All those extra steps and dis-contiguous paths just throw away the beauty of the edit/run loop that makes Perl (and other dynamic languages) such a delight to program. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by petdance (Parson) on Jan 06, 2007 at 17:21 UTC | |