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   168 use v5.12.0;
  11         42  
2             package Test::Routine::Common 0.032;
3             # ABSTRACT: a role composed by all Test::Routine roles
4              
5 11     11   80 use Moose::Role;
  11         24  
  11         90  
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   84610 use Test::Abortable 0.002 ();
  11         490055  
  11         416  
15 11     11   87 use Test2::API 1.302045 ();
  11         177  
  11         328  
16              
17 11     11   5750 use namespace::autoclean;
  11         83859  
  11         50  
18              
19       22 0   sub BUILD {
20             }
21              
22       22 0   sub DEMOLISH {
23             }
24              
25             sub run_test {
26 44     44 0 323 my ($self, $test) = @_;
27              
28 44         166 my $ctx = Test2::API::context();
29 44         3937 my ($file, $line) = @{ $test->_origin }{ qw(file line) };
  44         2420  
30 44         218 $ctx->trace->set_detail("at $file line $line");
31              
32 44         553 my $name = $test->name;
33              
34             # Capture and return whether the test as a whole succeeded or not
35 44     44   1880 my $rc = Test::Abortable::subtest($test->description, sub { $self->$name });
  44         37177  
36              
37 44         125570 $ctx->release;
38              
39 44         442 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.032
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
67             released in the last two to three years. (That is, if the most recently
68             released version is v5.40, then this module should work on both v5.40 and
69             v5.38.)
70              
71             Although it may work on older versions of perl, no guarantee is made that the
72             minimum required version will not be increased. The version may be increased
73             for any reason, and there is no promise that patches will be accepted to
74             lower the minimum required perl.
75              
76             =head1 AUTHOR
77              
78             Ricardo Signes <cpan@semiotic.systems>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2010 by Ricardo Signes.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut