File Coverage

blib/lib/Test/Class/Moose/Config.pm
Criterion Covered Total %
statement 20 25 80.0
branch 0 2 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 28 36 77.7


line stmt bran cond sub pod time code
1             package Test::Class::Moose::Config;
2              
3             # ABSTRACT: Configuration information for Test::Class::Moose
4              
5 34     34   274 use strict;
  34         89  
  34         1160  
6 34     34   208 use warnings;
  34         78  
  34         1031  
7 34     34   202 use namespace::autoclean;
  34         75  
  34         286  
8              
9 34     34   2871 use 5.010000;
  34         133  
10              
11             our $VERSION = '0.99';
12              
13 34     34   261 use Moose;
  34         197  
  34         311  
14 34     34   243792 use Moose::Util::TypeConstraints;
  34         77  
  34         387  
15              
16 34     34   99731 use Test::Class::Moose::Deprecated;
  34         102  
  34         157  
17              
18             subtype 'ArrayRefOfStrings', as 'Maybe[ArrayRef[Str]]';
19              
20             coerce 'ArrayRefOfStrings', from 'Str', via { defined($_) ? [$_] : undef };
21              
22             has 'show_timing' => (
23             is => 'ro',
24             isa => 'Bool',
25             lazy => 1,
26             default => sub {
27             if ( $_[0]->use_environment and $ENV{HARNESS_IS_VERBOSE} ) {
28             return 1;
29             }
30             return;
31             },
32             );
33              
34             has 'set_process_name' => (
35             is => 'ro',
36             isa => 'Bool',
37             default => 0,
38             );
39              
40             has 'statistics' => (
41             is => 'ro',
42             isa => 'Bool',
43             lazy => 1,
44             default => sub {
45             if ( $_[0]->use_environment and $ENV{HARNESS_IS_VERBOSE} ) {
46             return 1;
47             }
48             return;
49             },
50             );
51              
52             has 'use_environment' => (
53             is => 'ro',
54             isa => 'Bool',
55             );
56              
57             has 'test_class' => (
58             is => 'ro',
59             isa => 'Str',
60             );
61              
62             has 'randomize' => (
63             is => 'ro',
64             isa => 'Bool',
65             default => 0,
66             );
67              
68             has 'randomize_classes' => (
69             is => 'ro',
70             isa => 'Bool',
71             default => 0,
72             );
73              
74             has 'include' => (
75             is => 'ro',
76             isa => 'Regexp',
77             );
78              
79             has 'exclude' => (
80             is => 'ro',
81             isa => 'Regexp',
82             );
83              
84             has 'include_tags' => (
85             is => 'ro',
86             isa => 'ArrayRefOfStrings',
87             coerce => 1,
88             clearer => 'clear_include_tags',
89             );
90              
91             has 'exclude_tags' => (
92             is => 'ro',
93             isa => 'ArrayRefOfStrings',
94             coerce => 1,
95             clearer => 'clear_exclude_tags',
96             );
97              
98             has 'test_classes' => (
99             is => 'ro',
100             isa => 'ArrayRefOfStrings',
101             coerce => 1,
102             );
103              
104             sub args {
105 0     0 1   my $self = shift;
106              
107 0           Test::Class::Moose::Deprecated::deprecated();
108              
109             return (
110 0 0         map { defined $self->$_ ? ( $_ => $self->$_ ) : () }
111 0           map { $_->name } $self->meta->get_all_attributes
  0            
112             );
113             }
114              
115             __PACKAGE__->meta->make_immutable;
116              
117             1;
118              
119             =pod
120              
121             =encoding UTF-8
122              
123             =head1 NAME
124              
125             Test::Class::Moose::Config - Configuration information for Test::Class::Moose
126              
127             =head1 VERSION
128              
129             version 0.99
130              
131             =head1 SYNOPSIS
132              
133             my $tc_config = Test::Class::Moose::Config->new({
134             show_timing => 1,
135             statistics => 1,
136             randomize => 0,
137             });
138             my $test_suite = Test::Class::Moose->new($tc_config);
139              
140             =head1 DESCRIPTION
141              
142             For internal use only (maybe I'll expose it later). Not guaranteed to be
143             stable.
144              
145             This class defines many of the attributes for L<Test::Class::Moose>. They're
146             kept here to minimize namespace pollution in L<Test::Class::Moose>.
147              
148             =head1 ATTRIBUTES
149              
150             =head2 C<show_timing>
151              
152             Boolean. Will display verbose information on the amount of time it takes each
153             test class/test method to run.
154              
155             =head2 C<statistics>
156              
157             Boolean. Will display number of classes, test methods and tests run.
158              
159             =head2 C<use_environment>
160              
161             Boolean. Sets show_timing and statistics to true if your test harness is
162             running verbosely, false otherwise.
163              
164             =head2 C<test_classes>
165              
166             Takes a class name or an array reference of class names. If it is present, the
167             C<test_classes> method will only return these classes. This is very useful if
168             you wish to run an individual class as a test:
169              
170             Test::Class::Moose->new(
171             test_classes => $ENV{TEST_CLASS}, # ignored if undef
172             )->runtests;
173              
174             =head2 C<include_tags>
175              
176             Array ref of strings matching method tags (a single string is also ok). If
177             present, only test methods whose tags match C<include_tags> or whose tags don't
178             match C<exclude_tags> will be included. B<However>, they must still start with
179             C<test_>.
180              
181             For example:
182              
183             my $test_suite = Test::Class::Moose->new({
184             include_tags => [qw/api database/],
185             });
186              
187             The above constructor will only run tests tagged with C<api> or C<database>.
188              
189             =head2 C<exclude_tags>
190              
191             The same as C<include_tags>, but will exclude the tests rather than include
192             them. For example, if your network is down:
193              
194             my $test_suite = Test::Class::Moose->new({
195             exclude_tags => [ 'network' ],
196             });
197              
198             # or
199             my $test_suite = Test::Class::Moose->new({
200             exclude_tags => 'network',
201             });
202              
203             =head2 C<randomize>
204              
205             Boolean. Will run test methods of a class in a random order.
206              
207             =head2 C<randomize_classes>
208              
209             Boolean. Will run test classes in a random order.
210              
211             =head1 METHODS
212              
213             =head2 C<args>
214              
215             Returns a hash of the args used to build the configuration. This used to be
216             used internally, but is now retained simply for backwards compatibility. You
217             probably won't need it.
218              
219             =head1 SUPPORT
220              
221             Bugs may be submitted at L<https://github.com/houseabsolute/test-class-moose/issues>.
222              
223             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
224              
225             =head1 SOURCE
226              
227             The source code repository for Test-Class-Moose can be found at L<https://github.com/houseabsolute/test-class-moose>.
228              
229             =head1 AUTHORS
230              
231             =over 4
232              
233             =item *
234              
235             Curtis "Ovid" Poe <ovid@cpan.org>
236              
237             =item *
238              
239             Dave Rolsky <autarch@urth.org>
240              
241             =back
242              
243             =head1 COPYRIGHT AND LICENSE
244              
245             This software is copyright (c) 2012 - 2021 by Curtis "Ovid" Poe.
246              
247             This is free software; you can redistribute it and/or modify it under
248             the same terms as the Perl 5 programming language system itself.
249              
250             The full text of the license can be found in the
251             F<LICENSE> file included with this distribution.
252              
253             =cut
254              
255             __END__
256              
257              
258             1;