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   390 use strict;
  30         80  
  30         1448  
6 30     30   314 use warnings;
  30         195  
  30         2133  
7 30     30   475 use namespace::autoclean;
  30         91  
  30         370  
8              
9 30     30   3713 use 5.010000;
  30         327  
10              
11             our $VERSION = '1.00';
12              
13 30     30   459 use Moose;
  30         67  
  30         263  
14 30     30   162611 use Carp;
  30         220  
  30         2549  
15 30     30   220 use Test::Class::Moose::AttributeRegistry;
  30         164  
  30         9718  
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 114 my ( $self, $integer ) = @_;
54 13   100     933 $self->tests_planned( ( $self->tests_planned || 0 ) + $integer );
55             }
56              
57             sub has_tag {
58 2     2 1 1419 my ( $self, $tag ) = @_;
59 2 50       8 croak('has_tag(\$tag) requires a tag name') unless defined $tag;
60 2         148 my $class = $self->instance->name;
61 2         94 my $method = $self->name;
62 2         23 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 1.00
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/Test-More/test-class-moose/issues>.
131              
132             =head1 SOURCE
133              
134             The source code repository for Test-Class-Moose can be found at L<https://github.com/Test-More/test-class-moose>.
135              
136             =head1 AUTHORS
137              
138             =over 4
139              
140             =item *
141              
142             Curtis "Ovid" Poe <ovid@cpan.org>
143              
144             =item *
145              
146             Dave Rolsky <autarch@urth.org>
147              
148             =item *
149              
150             Chad Granum <exodist@cpan.org>
151              
152             =back
153              
154             =head1 COPYRIGHT AND LICENSE
155              
156             This software is copyright (c) 2012 - 2025 by Curtis "Ovid" Poe.
157              
158             This is free software; you can redistribute it and/or modify it under
159             the same terms as the Perl 5 programming language system itself.
160              
161             The full text of the license can be found in the
162             F<LICENSE> file included with this distribution.
163              
164             =cut