Stories
Slash Boxes
Comments
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

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

jplindstrom
  (email not shown publicly)

Journal of jplindstrom (594)

Monday September 03, 2007
12:18 PM

use Test::More tests = 1000;

[ #34326 ]

During YAPC I observed someone[1] writing tests, putting

use Test::More tests => 1000;

at the top of the .t file, and I realized -- I do that too! All the time.

There is a simple reason for this behaviour.

When you run prove and there are fewer tests than in the test plan, it's fairly evident how many tests were run from the output. So it's easy to stick that number into the test plan once the tests work.

When you add more tests without updating the test count, the output says "Looks like you planned 47 tests but ran 27 extra". There is no final count of tests run.

Being the lazy bugger I am I refuse to do that simple math operation in my head (because it's not simple, it makes my brane hurt and I risk getting it wrong). Instead I put 1000 at the top to get the answer served on a plate, which is what computers should do as much as possible[2].

TAPx::Parser's runtests to the rescue. Using that test-runner instead of prove doesn't only give me colored output, I also get a sane test count:

"You planned 47 tests but ran 74"

Actually I didn't realize runtests did this wonderful thing. This whole journal entry was supposed to be a bit of whining that prove didn't do the right thing damnit, and then when I ran some tests to give me the bad output it turned out to be fixed already!

So all this time I have been fiddling with

use Test::More tests => 1000;

for nothing. Doh!

Well, now I know. Problem solved. By whining.

[1] Edmund, how's it going with that smoke-performance-regression-over-time thingy?

[2] Serve me things. On a plate. Because no-one else does.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.