File Coverage

blib/lib/Test/Class/Moose/Config.pm
Criterion Covered Total %
statement 14 19 73.6
branch 0 2 0.0
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 20 28 71.4


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