Test::Cookbook

Ovid on 2004-12-07T22:05:40

We need a Test::Cookbook. From my recent post to the Perl QA List:

Problem:

POD is incomplete in a module but you still want to test POD coverage with something like Test::Pod::Coverage::all_pod_coverage_ok().

Solution:

Have a hash of modules to skip and use TPC's all_modules() function to ensure you don't miss new modules.

  use strict;
  use Test::More;
  eval "use Test::Pod::Coverage 0.08";
  plan $@
    ? (skip_all => "Test::Pod::Coverage needed to test POD coverage");
    : (tests => scalar @modules);

  my %TODO    = map { $_ => 1 } @modules_with_incomplete_pod;
  my @modules = Test::Pod::Coverage::all_modules();

  foreach my $module (@modules) {
    if (exists $TODO{$module}) {
      TODO: {
        local $TODO = "Known incomplete POD for $module";
        pod_coverage_ok($module);
      };
    }
    else {
      pod_coverage_ok($module);
    }
  }

Discussion.

Actually, I'd rather have a Test::Cookbook discussion. You can see the intent of the above code. It's not perfect (and I'm open to suggestions for improvement), but it's something that is not immediately obvious to someone who just started testing. Frankly, I don't care if Test::Cookbook was a wiki, a POD document or something else entirely (such as a book!), but something like this would be terribly useful.


Book

djberg96 on 2004-12-07T22:10:54

Actually, I'd rather have a Test::Cookbook discussion.

Actually, I'd rather have a "Unit Testing with Perl" book. It could cover:

  • Basic testing (Test::Simple)
  • Advanced testing (Test::More)
  • Object Oriented tests (Test::Class, etc)
  • Test harnesses/runners (Test::Harness,etc)
  • Mock objects
Whaddya think?

Re:Book

Ovid on 2004-12-07T22:38:01

As a book, your idea is better. Barring that, I think a Test::Cookbook POD page would be a good idea.

Re:Book

petdance on 2004-12-07T22:44:27

Hmmm, a book. That's an interesting idea...

Re:Book

Ovid on 2004-12-08T00:06:26

Yes. Yes it is. Slacker.

Re:Book

djberg96 on 2004-12-08T18:01:31

Does that mean you're already writing one?

Re:Book

petdance on 2004-12-08T18:41:41

Hmmm. No, I'm not, at this moment, writing one.

Right now, I'm going to lunch.

Re:Book

jdavidb on 2004-12-08T18:46:02

Well, get back to work so we can have our book!

Re:Book

MarkyMoon on 2004-12-09T04:36:24

Do it!

Re:Book

DarkBlue on 2004-12-08T10:49:34

That's a great idea, I would buy this book. Come on O'Reilly.