Software Testing

Functional

Non-functional

Non-functional Testing

Performance

Load

Usability

Security

Localisation

Functional Testing

Unit

Integration

UI

Regression

Smoke

Exploratory

End-to-end

Acceptance

Perl

Perl has a history of testing

Perl version 1 included tests

CPAN

Most CPAN modules include tests

Modules tests are run upon installation

CPANTesters

TAP

Test Anything Protocol

            
              1..4
              ok 1 - Input file opened
              not ok 2 - First line of the input valid
              ok 3 - Read the rest of the file
              not ok 4 - Summarised correctly  # TODO - not written yet
            
          
            
              1..4
              ok 1 - Input file opened
              not ok 2 - First line of the input valid
              ok 3 - Read the rest of the file
              not ok 4 - Summarised correctly  # TODO - not written yet
            
          
            
              1..4
              ok 1 - Input file opened
              not ok 2 - First line of the input valid
              ok 3 - Read the rest of the file
              not ok 4 - Summarised correctly  # TODO - not written yet
            
          
            
              1..4
              ok 1 - Input file opened
              not ok 2 - First line of the input valid
              ok 3 - Read the rest of the file
              not ok 4 - Summarised correctly  # TODO - not written yet
            
          
            
              1..4
              ok 1 - Input file opened
              not ok 2 - First line of the input valid
              ok 3 - Read the rest of the file
              not ok 4 - Summarised correctly  # TODO - not written yet
            
          
            
              1..4
              ok 1 - Input file opened
              not ok 2 - First line of the input valid
              ok 3 - Read the rest of the file
              not ok 4 - Summarised correctly  # TODO - not written yet
            
          

TAP

Producer

Consumer

TAP Consumers

you

Test::Harness

make test

prove

Test2::Harness

yath

TAP Producers

print

            
              #!/usr/bin/env perl
              use Reader;

              say "1..2";
              my $reader = Reader->new("test_data");
              print "not " unless $reader;
              say "ok 1 - Input file opened";
              my $first_line = $reader->read;
              print "not " unless $first_line eq "START";
              say "ok 2 - First line of input valid";
            
          

Test.pm

            
              #!/usr/bin/env perl
              use Test;
              use Reader;
              BEGIN { plan tests => 2 }

              my $reader = Reader->new("test_data");
              ok $reader;
              my $first_line = $reader->read;
              ok $first_line, "START", "First line of input valid";
            
          

Test::Simple

            
              #!/usr/bin/env perl
              use Test::Simple tests => 2;
              use Reader;

              my $reader = Reader->new("test_data");
              ok $reader, "Input file opened";
              my $first_line = $reader->read;
              ok $first_line eq "START", "First line of input valid";
            
          

Test::More

            
              #!/usr/bin/env perl
              use Test::More tests => 2;
              use Reader;

              my $reader = Reader->new("test_data");
              ok $reader, "Input file opened";
              my $first_line = $reader->read;
              is $first_line, "START", "First line of input valid";
            
          

Test::Most

            
              #!/usr/bin/env perl
              use Test::Most tests => 2;
              use Reader;

              my $reader = Reader->new("test_data");
              ok $reader, "Input file opened";
              my $first_line = $reader->read;
              is $first_line, "START", "First line of input valid";
            
          

Test::Class (part 1)

            
              package Reader::Test;
              use base qw( Test::Class );
              use Test::More;
              use Reader;

              sub make_fixture : Test(setup) {
                  shift->{reader} = Reader->new("test_data");
              }

              sub reader : Test(2) {
                  my $reader = shift->{reader};
                  ok $reader, "Input file opened";
                  my $first_line = $reader->read;
                  is $first_line, "START", "First line of input valid";
              }
            
          

Test::Class (part 2)

            
              #!/usr/bin/env perl
              use Reader::Test;

              Test::Class->runtests;
            
          

Test::Class::Moose (part 1)

            
              package TestFor::Reader;
              use Test::Class::Moose;
              use Reader;

              has reader => is => "ro", isa => "Reader";

              sub test_setup { shift->reader(Reader->new("test_data")) }

              sub test_reader {
                  my $reader = shift->reader;
                  ok $reader, "Input file opened";
                  my $first_line = $reader->read;
                  is $first_line, "START", "First line of input valid";
              }
            
          

Test::Class::Moose (part 2)

            
              #!/usr/bin/env perl
              use Test::Class::Moose::CLI;

              Test::Class::Moose::CLI->new_with_options->run;
            
          

Test2

            
              #!/usr/bin/env perl
              use Test2::Bundle::More;
              use Reader;
              plan 2;

              my $reader = Reader->new("test_data");
              ok $reader, "Input file opened";
              my $first_line = $reader->read;
              is $first_line, "START", "First line of input valid";
            
          

Which one to use?

Opinion is divided on the subject

Which one to use?

It's just a test

Tests are code too

(Your test code should be simpler
than the code it is testing, yes?)

Joshua Pritikin, author of Test.pm

TAP Producers

print

Test.pm

Test::Simple

Test::More

Test::Most

Test::Class

Test::Class::Moose

Test2

I don't trust my tests

Coverage

Time

My tests are too slow

Run them in parallel

Profile

Test::Class

DRY

I spend too long fixing my tests after making a code change

Testing at the wrong level

I spend too long fixing my tests after making a code change

Testing at the wrong level

UI tests instead of Unit tests

Units tests tightly coupled to implementation rather than API