File Coverage

blib/lib/Test/Class/Moose/Report/Method.pm
Criterion Covered Total %
statement 16 21 76.1
branch 0 2 0.0
condition 2 2 100.0
subroutine 6 7 85.7
pod 1 2 50.0
total 25 34 73.5


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