NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Perhaps you've chosen a bad example... (Score:1)
It seems to me that the example you give is ultimately a poor test. You’re relying upon an implicit feature of the testing interface to test for explicit behaviors of your code. As a person new to your project how I am supposed to know that
list()is only ever supposed to return two elements? Sure the tests fail but how do I know that the tests were correct in the first place?By making an explicit test for the explicit behavior, I can communicate to someone else that I’m expecting
list()to onlRe: (Score:2)
I agree with your assessment of no_plan, at least when you used it you were explicitly saying there was no plan...
Re: (Score:1)
--fREW
http://blog.afoolishmanifesto.com
Re: (Score:1)
done_testingfor future code.Re: (Score:2)
no_plan won't detect early termination, but Test::Harness will note the non-zero exit status on a die.
Re: (Score:1)
It is more common than I'd like to see END and DESTROY blocks do something that clears the exit status of a Perl program on its way out the door.
In fact it is common enough that I'd prefer not to rely on it to detect abnormal ending of a test suite. Particularly since many test suites like to do cleanup when they are done.
Gotta have a plan ... (Score:2)
The Aegis software management tool has been around for a long time [wikipedia.org], but I strongly suspect that part of the reason it never became very popular is because it enforced a particular belief on users. For example, your code is always in one of multiple stages and for the "being developed" state, you cannot check in unless you have new tests and your code must pass those tests. There are numerous other states and numerous other preconditions which developers much satisfy before they can move the code to the n
Re: (Score:1)
Are we talking about organised religion or programming? I find the language in your last couple of comments… creepy.
Re: (Score:2)
The religious allusions were deliberate. The dogmatism of those who insist that we "must have a plan" put people off in the same way that dogmatists for anything will put off certain parts of the population. I don't care for dogmatism because it's often a fancy word for "we think we understand this, so we don't need critical thought". Since dogmatism is often accompanied by a near religious fervor, I thought it was OK to continue with the metaphor.
Sorry if I was a little too zealous in that. Obviously i
Re:Gotta have a plan … (Score:1)
You lost me when you started talking about bringing people into the fold and such. I want to teach trade-offs and how to weigh them, not convert people to a doctrine – any doctrine.
Re: (Score:2)
My apologies. I meant that strictly as tongue-in-cheek. I should hope that that those who know me would appreciate the irony of me using religious allusions. I'm not serious, dude :)
Re: (Score:1)
I know, which was part of why I was a little taken aback. All good then. :-)
Re: (Score:2)
We've never insisted on a plan, you just had to explicitly say that you didn't have one.
What I'm seeing now is the opposite, you (and others) seem to be actively encouraging people to NOT use plans. Or at least, that is the impression I get.
People have never HAD to use DBI placeholders either, but the default documentation comprehensively refers to it.
Re: (Score:2)
Not using DBI placeholders is far more serious than not using a plan. It's can leave you wide open to serious security holes. Lack of a plan, however, while risky, is far less risky.
When I'm moving, my friends and I are carrying stuff into my house and I leave the door unlocked. I lock the door when I'm done. Similarly, when I write tests, I set them as no_plan and add the plan when I'm done. What I want to do is minimize the accounting when writing tests and when the developer is done, they lock the d
done_testing( $arg )? (Score:1)
I like to use the argument done_testing accepts that lets you say how many tests you expected to have run at that stage.
Its like specifying a plan, except you can do so pro grammatically after the fact, which eliminates the need for tedious manual counting.
All you need to know is how many tests occur within a given block of code and increment your counter respectively.
use Test::More;
my $t;
$t+=2;
foreach ( list() ) {
ok( $_, 'List member ok' );
}
$t+=3; # list called the second time
Re: (Score:1)
Re: (Score:2)
There's surely a better way to get the same effect.
Switch to Test::Class. I've an [cpan.org]extensive article on its use and best practices [slideshare.net]. When nested TAP is finally stable, Adrian Howard has a new version available which utilizes it. It's much cleaner.
Re: (Score:2)
I've found that that Test::Class testing code is significantly harder to maintain that the "bunch of Perl scripts" of the regular way.
That's just me though...
Re: (Score:1)
Yes, this seems the way to go to me, especially since I have been writing my tests like
for quite a while now. AFAIC
done_testing($tests)simply removes the need for the uglyBEGINblocks.The other thing I quite like about
done_testingis that is removes the need forSKIP:blNew fancy stuff breaking my CPAN :) (Score:1)
Re: (Score:2)
That is just the regular kind of stupid, forgetting that because you are using new syntax, you need new versions in your deps.
Re: (Score:2)
It should be fairly easy to write a detector for too, just look for done_testing in modules and compare it to their META.yml.
Re: (Score:1)
This is where it comes in extra handy that :-)
done_testinghas a stupidly (or so it would seem) long name.updating the plan in your editor (Score:1)
Funny, I just added a feature to do that for emacs, it's in the latest release of my perlnow.el [obsidianrook.com].
If you run a *.t file from inside of emacs using perlnow.el, you can then do a "perlnow-revise-test-plan" which changes the plan to match the number of tests you actually ran.
Right tool for the right job (Score:1)
Is there *any* conceivable reason to have to know how many tests are in fact being executed in [2]?
Cheers