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   1020 use strict;
  98         192  
  98         2471  
3 98     98   513 use warnings;
  98         211  
  98         2336  
4              
5 98     98   1048 use Test::Stream::Plugin;
  98         176  
  98         696  
6              
7             my $ADDED_HOOK = 0;
8             sub load_ts_plugin {
9 115     115 0 617 require Test::Stream::Sync;
10 115 100       916 Test::Stream::Sync->add_hook(\&summary) unless $ADDED_HOOK++;
11             }
12              
13             sub summary {
14 96     96 0 287 my ($ctx, $real, $new) = @_;
15              
16 96         448 my $state = $ctx->hub->state;
17 96         843 my $plan = $state->plan;
18 96         533 my $count = $state->count;
19 96         590 my $failed = $state->failed;
20              
21 96 100 100     769 $ctx->diag('No tests run!') if !$count && (!$plan || $plan ne 'SKIP');
      66        
22 96 100 100     768 $ctx->diag('Tests were run but no plan was declared and done_testing() was not seen.')
23             if $count && !$plan;
24              
25 96 100       382 $ctx->diag("Looks like your test exited with $real after test #$count.")
26             if $real;
27              
28 96 100 100     2010 $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__