File Coverage

blib/lib/Test/Routine/Common.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 0 3 0.0
total 33 36 91.6


line stmt bran cond sub pod time code
1 11     11   181 use v5.12.0;
  11         46  
2             package Test::Routine::Common 0.031;
3             # ABSTRACT: a role composed by all Test::Routine roles
4              
5 11     11   68 use Moose::Role;
  11         31  
  11         83  
6              
7             #pod =head1 OVERVIEW
8             #pod
9             #pod Test::Routine::Common provides the C<run_test> method described in L<the docs
10             #pod on writing tests in Test::Routine|Test::Routine/Writing Tests>.
11             #pod
12             #pod =cut
13              
14 11     11   69769 use Test::Abortable 0.002 ();
  11         454839  
  11         349  
15 11     11   88 use Test2::API 1.302045 ();
  11         138  
  11         242  
16              
17 11     11   5213 use namespace::autoclean;
  11         70244  
  11         51  
18              
19       22 0   sub BUILD {
20             }
21              
22       22 0   sub DEMOLISH {
23             }
24              
25             sub run_test {
26 44     44 0 249 my ($self, $test) = @_;
27              
28 44         115 my $ctx = Test2::API::context();
29 44         2895 my ($file, $line) = @{ $test->_origin }{ qw(file line) };
  44         1537  
30 44         202 $ctx->trace->set_detail("at $file line $line");
31              
32 44         489 my $name = $test->name;
33              
34             # Capture and return whether the test as a whole succeeded or not
35 44     44   1277 my $rc = Test::Abortable::subtest($test->description, sub { $self->$name });
  44         30597  
36              
37 44         103154 $ctx->release;
38              
39 44         403 return $rc;
40             }
41              
42             1;
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             Test::Routine::Common - a role composed by all Test::Routine roles
53              
54             =head1 VERSION
55              
56             version 0.031
57              
58             =head1 OVERVIEW
59              
60             Test::Routine::Common provides the C<run_test> method described in L<the docs
61             on writing tests in Test::Routine|Test::Routine/Writing Tests>.
62              
63             =head1 PERL VERSION
64              
65             This module should work on any version of perl still receiving updates from
66             the Perl 5 Porters. This means it should work on any version of perl released
67             in the last two to three years. (That is, if the most recently released
68             version is v5.40, then this module should work on both v5.40 and v5.38.)
69              
70             Although it may work on older versions of perl, no guarantee is made that the
71             minimum required version will not be increased. The version may be increased
72             for any reason, and there is no promise that patches will be accepted to lower
73             the minimum required perl.
74              
75             =head1 AUTHOR
76              
77             Ricardo Signes <cpan@semiotic.systems>
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2010 by Ricardo Signes.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             =cut