You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site.

5.8. Introducing Test::Simple

Example 5-10. examples/intro/t05_calc.t

#!/usr/bin/perl
use strict;
use warnings;

# tell how many tests you are going to write. This is our "plan"
use Test::Simple tests => 3;

# the ok function of Test::Simple prints "ok" or "not ok"
ok `./mycalc 1 + 1` == 2;
ok `./mycalc 2 + 2` == 4;
ok `./mycalc 2 + 2 + 2` == 6;

Output:

Example 5-11. examples/intro/t05_calc.out

1..3
ok 1
ok 2
not ok 3
#   Failed test in t05_calc.t at line 11.
# Looks like you failed 1 test of 3.

It is more verbose, it has a couple of additional useful piece of information: 1..3 says how many tests we were planning then we get the tests numbered and we even get a small explanation when the test fails.


If you are interested in on-site trainings by the author, please contact me directly.