line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::FITesque::Suite; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
62697
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
155
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
419
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
288
|
use Test::Builder; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
2176
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $TEST_BUILDER; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Test::FITesque::Suite - FITesque test suite runner |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $suite = Test::FITesque::Suite->new(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $test = Test::FITesque::Test->new(); |
19
|
|
|
|
|
|
|
my $suite2 = Test::FITesque::Suite->new(); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
... |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$suite->add($test, $suite2, ...); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $test_count = $suite->test_count(); |
26
|
|
|
|
|
|
|
$suite->run_tests(); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This package provides a way of running a suite of tests. It also allowd you to |
31
|
|
|
|
|
|
|
run suites of suites in whatever hierarchy you see fit. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $suite = Test::FITesque::Suite->new(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This method is a simple constructor, but can take a single parameter within a |
40
|
|
|
|
|
|
|
hashref: |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item data |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This takes a simple arrayref of tests or suites. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=back |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
53
|
11
|
|
|
11
|
1
|
2709
|
my ($class, $args) = @_; |
54
|
11
|
|
100
|
|
|
58
|
$args ||= {}; |
55
|
11
|
|
|
|
|
27
|
my $self = bless $args, $class; |
56
|
11
|
|
|
|
|
35
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 add |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$suite->add($test, $suite2, ...); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This method allows you to add tests or suites to the current suite object. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub add { |
68
|
9
|
|
|
9
|
1
|
91
|
my ($self, @tests) = @_; |
69
|
9
|
|
100
|
|
|
54
|
$self->{data} ||= []; |
70
|
9
|
|
|
|
|
22
|
my $data = $self->{data}; |
71
|
9
|
|
|
|
|
24
|
for my $test (@tests){ |
72
|
12
|
100
|
100
|
|
|
134
|
die "Attempted to add a test that was not a FITesque test" |
73
|
|
|
|
|
|
|
if !($test->isa(q{Test::FITesque::Test}) || $test->isa(q{Test::FITesque::Suite})); |
74
|
|
|
|
|
|
|
} |
75
|
8
|
|
|
|
|
55
|
push @$data, @tests; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 test_count |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $count = $suite->test_count(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This method returns the test count for all tests within the suite. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub test_count { |
87
|
16
|
|
|
16
|
1
|
37
|
my ($self) = @_; |
88
|
|
|
|
|
|
|
|
89
|
16
|
|
|
|
|
24
|
my $count = 0; |
90
|
16
|
|
|
|
|
23
|
for my $test (@{ $self->{data} }){ |
|
16
|
|
|
|
|
41
|
|
91
|
28
|
|
|
|
|
108
|
$count += $test->test_count(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
16
|
|
|
|
|
70
|
return $count; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 run_tests |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$suite->run_tests(); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This method will run all tests within a suite. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub run_tests { |
106
|
9
|
|
|
9
|
1
|
506
|
my ($self) = @_; |
107
|
|
|
|
|
|
|
|
108
|
9
|
|
100
|
|
|
49
|
my $data = $self->{data} || []; |
109
|
|
|
|
|
|
|
|
110
|
9
|
100
|
|
|
|
40
|
die "Attempting to run a suite with no tests" if !@$data; |
111
|
|
|
|
|
|
|
|
112
|
8
|
|
|
|
|
29
|
my ($pkg) = caller(); |
113
|
8
|
100
|
|
|
|
149
|
if(!$pkg->isa('Test::FITesque::Suite')){ |
114
|
5
|
100
|
|
|
|
32
|
my $Builder = $TEST_BUILDER ? $TEST_BUILDER : Test::Builder->new(); |
115
|
5
|
|
|
|
|
33
|
$Builder->exported_to(__PACKAGE__); |
116
|
5
|
100
|
|
|
|
28
|
if( my $count = $self->test_count() ){ |
117
|
4
|
|
|
|
|
22
|
$Builder->expected_tests($count); |
118
|
|
|
|
|
|
|
} else { |
119
|
1
|
|
|
|
|
7
|
$Builder->no_plan(); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
8
|
|
|
|
|
375
|
for my $test (@$data){ |
124
|
15
|
|
|
|
|
1365
|
$test->run_tests(); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Scott McWhirter, C<< >> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright 2007 Scott McWhirter, all rights reserved. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This program is released under the following license: BSD. Please see the |
137
|
|
|
|
|
|
|
LICENSE file included in this distribution for details. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |