NAME

Test::Inspector - are you testing everything?

SYNOPSIS

my $inspector = Test::Inspector->setup({
  modules => [ 'Foo::Bar', 'Bar::Baz', ... ],
  dirs    => [ '/path/to/test/dir1', '/path/to/test/dir2', ... ],
  ignore  => [ 'import_from_elsewhere_method1', 'also_imported', ... ],
  private => 1, # tests *all* methods, don't ignore ones that start _
});

print $inspector->inspect;

DESCRIPTION

Ever been asked to write tests for an unknown codebase? A large codebase, that may, or may not, have tests associated with it? How do you know if you need to test a method? Is it already tested?

This doesn't answer those questions per se. It tries to make a first best stab at it for you.

Supply a list of modules, supply a list of test directories, and we see if the methods in the modules are called anywhere in those directories. It doesn't mean that the tests are good, but it might help you in where to add a new test, or which tests you should be running.

If you import methods into a module, you may not want to know if they are tested by your good self. That should be up to the exporting module's test suite, right? Using the 'ignore' key to the hashref or args, you can say you don't care about those methods. Like, say, in this itself, I use File::Find, but don't really want to be worrying about if I have tested 'find' or 'finddepth'. Y'see?

METHODS

setup

my $inspector = Test::Inspector->setup({
  modules => [ 'Foo::Bar', 'Bar::Baz', ... ],
  dirs    => [ '/path/to/test/dir1', '/path/to/test/dir2', ... ],
  ignore  => [ 'import_from_elsewhere_method1', 'also_imported', ... ],
  private => 1, # tests *all* methods, don't ignore ones that start _
});

Set the Inspector up with some modules and directories. Both passed in as listrefs in the keys of the hashref.

inspect

my %report = $inspector->inspect;

This will inspect the tests to see if all the methods in the module were referenced in any way.

pretty_report

print $inspector->pretty_report;

As it says, this is pretty report. The output looks like:

 Module::Name
   test_script_name
     method_name1 => FOUND
     method_name2 => NOT FOUND
...

OK, so it is a report, not that pretty. If you want to know how much time I spent on this in total...wait! come back!

NOTES

Look, you might have worked out, this is a first-pass attempt, it is dumb, could probably be done better using other modules, yadayadayada. It isn't meant to be the One True Answer for checking to make sure you have tested all your methods. It is a crude tool used to aid you somewhat. It might do, it might not, if it doesn't, then use something else!

BUGS

When you use the script itself to try and self-test, it all gets a bit self-referential doesn't it? Probably not the best code I have ever written, but probably more useful that all the other stuff. Who am I kidding?

TODO

o Stuff, no doubt. This did what I wanted it to do, in a crude way.

AUTHOR

(c) Stray Toaster 2007.