So why are those numbers necessary? Imagine you managed to write 200 unit tests. Somone who does not know about the number runs the test suite and sees "ok" printed 17 times. It looks like everything is ok. He won't notice that instead of 200, only 17 tests ran before the test script excited. Everything was OK up to that point, but there is a serious problem somewhere. Either in the application or in the test itself. This can be found only if the test executer knows how many test have you planned, and checks if the correct number of tests have been executed.
This is exactly what Test::Simple provides. In the following example we deliberately commented out the last test that was failing.
use strict; use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; use MyTools; use Test::Simple tests => 3; ok( sum(1, 1) == 2 ); ok( sum(2, 2) == 4 ); exit(0); # remove this after previous test is fixed ok( sum(3, 3) == 6 );
1..3 ok 1 ok 2 # Looks like you planned 3 tests but ran 2.