File Coverage

blib/lib/Test/Class/Moose/Report/Method.pm
Criterion Covered Total %
statement 27 27 100.0
branch 1 2 50.0
condition 2 2 100.0
subroutine 9 9 100.0
pod 1 2 50.0
total 40 42 95.2


line stmt bran cond sub pod time code
1             package Test::Class::Moose::Report::Method;
2              
3             # ABSTRACT: Reporting on test methods
4              
5 30     30   346 use strict;
  30         93  
  30         1178  
6 30     30   327 use warnings;
  30         73  
  30         1085  
7 30     30   410 use namespace::autoclean;
  30         67  
  30         343  
8              
9 30     30   3455 use 5.010000;
  30         126  
10              
11             our $VERSION = '0.99';
12              
13 30     30   204 use Moose;
  30         66  
  30         262  
14 30     30   158837 use Carp;
  30         85  
  30         2783  
15 30     30   252 use Test::Class::Moose::AttributeRegistry;
  30         81  
  30         10599  
16              
17             with qw(
18             Test::Class::Moose::Role::Reporting
19             );
20              
21             has test_setup_method => (
22             is => 'rw',
23             isa => 'Test::Class::Moose::Report::Method',
24             writer => 'set_test_setup_method',
25             );
26              
27             has test_teardown_method => (
28             is => 'rw',
29             isa => 'Test::Class::Moose::Report::Method',
30             writer => 'set_test_teardown_method',
31             );
32              
33             has 'instance' => (
34             is => 'ro',
35             isa => 'Test::Class::Moose::Report::Instance',
36             required => 1,
37             weak_ref => 1,
38             );
39              
40             has 'num_tests_run' => (
41             is => 'rw',
42             isa => 'Int',
43             default => 0,
44             );
45              
46             has 'tests_planned' => (
47             is => 'rw',
48             isa => 'Int',
49             predicate => 'has_plan',
50             );
51              
52             sub plan {
53 13     13 0 50 my ( $self, $integer ) = @_;
54 13   100     436 $self->tests_planned( ( $self->tests_planned || 0 ) + $integer );
55             }
56              
57             sub has_tag {
58 2     2 1 1055 my ( $self, $tag ) = @_;
59 2 50       6 croak('has_tag(\$tag) requires a tag name') unless defined $tag;
60 2         78 my $class = $self->instance->name;
61 2         62 my $method = $self->name;
62 2         16 return Test::Class::Moose::AttributeRegistry->method_has_tag(
63             $class,
64             $method,
65             $tag
66             );
67             }
68              
69             __PACKAGE__->meta->make_immutable;
70              
71             1;
72              
73             __END__
74              
75             =pod
76              
77             =encoding UTF-8
78              
79             =head1 NAME
80              
81             Test::Class::Moose::Report::Method - Reporting on test methods
82              
83             =head1 VERSION
84              
85             version 0.99
86              
87             =head1 DESCRIPTION
88              
89             Should be considered experimental and B<read only>.
90              
91             =for Pod::Coverage plan
92              
93             =head1 IMPLEMENTS
94              
95             L<Test::Class::Moose::Role::Reporting>.
96              
97             =head1 ATTRIBUTES
98              
99             See L<Test::Class::Moose::Role::Reporting> for additional attributes.
100              
101             =head2 C<instance>
102              
103             The L<Test::Class::Moose::Report::Instance> for this method.
104              
105             =head2 C<num_tests_run>
106              
107             my $tests_run = $method->num_tests_run;
108              
109             The number of tests run for this test method.
110              
111             =head2 C<tests_planned>
112              
113             my $tests_planned = $method->tests_planned;
114              
115             The number of tests planned for this test method. If a plan has not been
116             explicitly set with C<$report->test_plan>, then this number will always be
117             equal to the number of tests run.
118              
119             =head2 C<has_tag>
120              
121             my $method = $test->test_report->current_method;
122             if ( $method->has_tag('db') ) {
123             $test->load_database_fixtures;
124             }
125              
126             Returns true if the current test method has the tag in question.
127              
128             =head1 SUPPORT
129              
130             Bugs may be submitted at L<https://github.com/houseabsolute/test-class-moose/issues>.
131              
132             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
133              
134             =head1 SOURCE
135              
136             The source code repository for Test-Class-Moose can be found at L<https://github.com/houseabsolute/test-class-moose>.
137              
138             =head1 AUTHORS
139              
140             =over 4
141              
142             =item *
143              
144             Curtis "Ovid" Poe <ovid@cpan.org>
145              
146             =item *
147              
148             Dave Rolsky <autarch@urth.org>
149              
150             =back
151              
152             =head1 COPYRIGHT AND LICENSE
153              
154             This software is copyright (c) 2012 - 2021 by Curtis "Ovid" Poe.
155              
156             This is free software; you can redistribute it and/or modify it under
157             the same terms as the Perl 5 programming language system itself.
158              
159             The full text of the license can be found in the
160             F<LICENSE> file included with this distribution.
161              
162             =cut