A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Perl test template

Comments: Logging may be mostly useful for debugging -- the log level can be raised for release.

#!/usr/bin/perl

#################################################################################
# Description of tests
#################################################################################

use strict;
use warnings;

use Test::More qw(no_plan);
use Test::Differences; # eq_or_diff()
use Test::Lazy qw/try check/; # check() displays the expected & actual upon failure, even for scalars
use Log::Log4perl;
use XML::Simple qw(:strict);

Log::Log4perl::init('conf/log4perl-test.conf');
my $LOG = Log::Log4perl->get_logger('log4perl.appender.LOGFILE');

$| = 1; select STDERR;
$| = 1; select STDOUT;

$LOG->info("Started tests");

use_ok('MyNamespace::MyModule');

dies_ok { MyNamespace::MyModule->new } 'fail to instantiate without parameters';

my $m = MyNamespace::MyModule->new( url => "foo", name => 'bar');
isa_ok($m, 'MyNamespace::MyModule');