File Coverage

blib/lib/Test/Stream/Plugin/ExitSummary.pm
Criterion Covered Total %
statement 20 20 100.0
branch 10 10 100.0
condition 16 18 88.8
subroutine 5 5 100.0
pod 0 2 0.0
total 51 55 92.7


line stmt bran cond sub pod time code
1             package Test::Stream::Plugin::ExitSummary;
2 98     98   661 use strict;
  98         111  
  98         2213  
3 98     98   307 use warnings;
  98         112  
  98         2039  
4              
5 98     98   642 use Test::Stream::Plugin qw/import/;
  98         118  
  98         457  
6              
7             my $ADDED_HOOK = 0;
8             sub load_ts_plugin {
9 116     116 0 454 require Test::Stream::Sync;
10 116 100       658 Test::Stream::Sync->add_hook(\&summary) unless $ADDED_HOOK++;
11             }
12              
13             sub summary {
14 96     96 0 173 my ($ctx, $real, $new) = @_;
15              
16 96         287 my $state = $ctx->hub->state;
17 96         491 my $plan = $state->plan;
18 96         281 my $count = $state->count;
19 96         385 my $failed = $state->failed;
20              
21 96 100 100     472 $ctx->diag('No tests run!') if !$count && (!$plan || $plan ne 'SKIP');
      66        
22 96 100 100     519 $ctx->diag('Tests were run but no plan was declared and done_testing() was not seen.')
23             if $count && !$plan;
24              
25 96 100       240 $ctx->diag("Looks like your test exited with $real after test #$count.")
26             if $real;
27              
28 96 100 100     1520 $ctx->diag("Did not follow plan: expected $plan, ran $count.")
      66        
      100        
29             if $plan && $plan =~ m/^\d+$/ && defined $count && $count != $plan;
30             }
31              
32             1;
33              
34             __END__