Precision Testing for Modern Perl

In a previous entry I discussed some of my favourite CPAN modules for testing Perl code.

I got to thinking... there are all these little frameworks on the CPAN like GID, and Modern::Perl, and Defaults::Modern, and Bubblegum which are basically little shims to load collections of "best practices" modules in a single line. For example:

So I went and wrote Test::Modern which combines Test::More, Test::Fatal, Test::Warnings, and more. It automatically imports strict and warnings for you, and enables Test::Warnings' had_no_warnings feature so that any unexpected warnings will cause your tests to fail. It provides the ability to mark test scripts as being author, release, or extended tests, and skip them based on the presence or absence of environment variables (like Test::DescribeMe), or skip tests based on missing dependencies (like Test::Requires).

Because much modern Perl code is quite object-oriented, it provides an object_ok function combining Test::More's isa_ok and can_ok, a Test::Moose-inspired does_ok, a Test::API-powered class_api_ok, and a Test::CleanNamespaces-cribbed namespaces_clean.

Is it likely to be everything you need to test every project in one module? No. But of course using Test::Modern doesn't stop you from using other test modules too!

Test::CleanNamespaces is back in active development and its underlying implementation is getting fixed up quite a lot, so it would probably be better to call into its version of clean_namespaces rather than copying its guts.