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.9. Add names to the tests

So Test::Simple makes our life a bit more simple in that we don't have to write our testing expression. In addition this new "ok" function can actually do some more favour. It can get two arguments. The first one indicates success or failure of the test and the second one is the name of the test. When running a test with these additional names they get printed on the same line where the "ok" or "not ok" is printed. In case of lots of tests it will make it easier to locate the test and if the names were written carefully they can provide an immediate hint what went wrong. Sometimes you won't even need to look at the test script itself, right from this comment you'll know where to look for the bug.

Example 5-12. examples/intro/t09_calc.t

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

use Test::Simple tests => 3;

ok `./mycalc 1 + 1` == 2,     'small sum: 1+1';
ok `./mycalc 2 + 2` == 4,     'small sum: 2+2';
ok `./mycalc 2 + 2 + 2` == 6, 'two operators: 2+2+2';

Output:

Example 5-13. examples/intro/t09_calc.out

1..3
ok 1 - small sum: 1+1
ok 2 - small sum: 2+2
not ok 3 - two operators: 2+2+2
#   Failed test 'two operators: 2+2+2'
#   in t09_calc.t at line 9.
# Looks like you failed 1 test of 3.

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