我在 t/ 下有一个简单的测试文件。我想在运行所有测试后显示摘要。由于某种原因,在显示“04.pl”的结果之前显示摘要。运行所有测试后如何显示摘要?
==> t/test.t
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
plan tests => 4;
require "/home/mydir/perl5/lib/perl5/TAP/Harness.pm";
require "/home/mydir/perl5/lib/perl5/TAP/Formatter/HTML.pm";
require "/home/mydir/perl5/lib/perl5/TAP/Parser/Aggregator.pm";
my $f = TAP::Formatter::HTML->new;
$f->verbosity(-1);
$f->force_inline_css(0);
my %args = (
formatter => $f,
merge => 1,
);
my $a = TAP::Parser::Aggregator->new;
my $h = TAP::Harness->new(\%args);
my @files = qw[01.pl 02.pl 03.pl 04.pl];
$a->start;
$h->aggregate_tests($a, @files);
$a->stop;
done_testing(4);
my $summary = <<'END_SUMMARY';
Total Tests: %s
Passed: %s
Failed: %s
Unexpectedly succeeded: %s
END_SUMMARY
printf $summary,
scalar $a->total,
scalar $a->passed,
scalar $a->failed,
scalar $a->todo_passed;
==> Output (in html format)
1..4
ok 1 - First
ok 1 - Second
ok 1 - Third
Total Tests: 4
Passed: 4
Failed: 0
Unexpectedly succeeded: 0
ok 1 - Four
为了运行测试,我使用了“prove”实用程序:/home/mydir/perl5/bin/prove -Q --formatter=TAP::Formatter::HTML > output.html