We need it because we have to report to the overlords how much testing we are doing.
Using the plan in the subtests doesn't work:
$ cat test.t
use Test::More;
subtest foo => sub {
plan_tests => 3;
ok 1;
ok 2;
ok 3;
};
$ prove -lrv test.t
test.t ..
# Subtest: foo
ok 1
ok 2
ok 3
1..3
ok 1 - foo
# Tests were run but no plan was declared and done_testing() was not s
+een.
Dubious, test returned 254 (wstat 65024, 0xfe00)
All 1 subtests passed
$ cat test.t
use Test::More;
subtest foo => sub {
plan_tests => 3;
ok 1;
ok 2;
ok 3;
};
done_testing;
$ prove -lrv test.t
test.t ..
# Subtest: foo
ok 1
ok 2
ok 3
1..3
ok 1 - foo
1..1
ok
All tests successful.
Files=1, Tests=1, ...
The way forward always starts with a minimal test.
|