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   1062 use strict;
  98         196  
  98         2583  
3 98     98   493 use warnings;
  98         214  
  98         2403  
4              
5 98     98   1079 use Test::Stream::Plugin;
  98         192  
  98         684  
6              
7             my $ADDED_HOOK = 0;
8             sub load_ts_plugin {
9 115     115 0 621 require Test::Stream::Sync;
10 115 100       929 Test::Stream::Sync->add_hook(\&summary) unless $ADDED_HOOK++;
11             }
12              
13             sub summary {
14 96     96 0 279 my ($ctx, $real, $new) = @_;
15              
16 96         444 my $state = $ctx->hub->state;
17 96         782 my $plan = $state->plan;
18 96         621 my $count = $state->count;
19 96         589 my $failed = $state->failed;
20              
21 96 100 100     791 $ctx->diag('No tests run!') if !$count && (!$plan || $plan ne 'SKIP');
      66        
22 96 100 100     841 $ctx->diag('Tests were run but no plan was declared and done_testing() was not seen.')
23             if $count && !$plan;
24              
25 96 100       375 $ctx->diag("Looks like your test exited with $real after test #$count.")
26             if $real;
27              
28 96 100 100     2057 $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__