line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::FITesque::Suite; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
31192
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
101
|
|
4
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
78
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
12
|
use Test::Builder; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1068
|
|
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
|
1844
|
my ($class, $args) = @_; |
54
|
11
|
|
100
|
|
|
36
|
$args ||= {}; |
55
|
11
|
|
|
|
|
18
|
my $self = bless $args, $class; |
56
|
11
|
|
|
|
|
19
|
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
|
59
|
my ($self, @tests) = @_; |
69
|
9
|
|
100
|
|
|
28
|
$self->{data} ||= []; |
70
|
9
|
|
|
|
|
9
|
my $data = $self->{data}; |
71
|
9
|
|
|
|
|
17
|
for my $test (@tests){ |
72
|
12
|
100
|
100
|
|
|
72
|
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
|
|
|
|
|
15
|
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
|
14
|
|
|
14
|
1
|
20
|
my ($self) = @_; |
88
|
|
|
|
|
|
|
|
89
|
14
|
|
|
|
|
11
|
my $count = 0; |
90
|
14
|
|
|
|
|
10
|
for my $test (@{ $self->{data} }){ |
|
14
|
|
|
|
|
20
|
|
91
|
24
|
|
|
|
|
48
|
$count += $test->test_count(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
14
|
|
|
|
|
41
|
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
|
254
|
my ($self) = @_; |
107
|
|
|
|
|
|
|
|
108
|
9
|
|
100
|
|
|
29
|
my $data = $self->{data} || []; |
109
|
|
|
|
|
|
|
|
110
|
9
|
100
|
|
|
|
21
|
die "Attempting to run a suite with no tests" if !@$data; |
111
|
|
|
|
|
|
|
|
112
|
8
|
|
|
|
|
18
|
my ($pkg) = caller(); |
113
|
8
|
100
|
|
|
|
97
|
if(!$pkg->isa('Test::FITesque::Suite')){ |
114
|
5
|
100
|
|
|
|
19
|
my $Builder = $TEST_BUILDER ? $TEST_BUILDER : Test::Builder->new(); |
115
|
5
|
|
|
|
|
17
|
$Builder->exported_to(__PACKAGE__); |
116
|
5
|
100
|
66
|
|
|
35
|
if ( $Builder->isa('Test::FakeBuilder') || !$Builder->has_plan) { |
117
|
4
|
100
|
|
|
|
9
|
if( my $count = $self->test_count() ){ |
118
|
3
|
|
|
|
|
9
|
$Builder->expected_tests($count); |
119
|
|
|
|
|
|
|
} else { |
120
|
1
|
|
|
|
|
3
|
$Builder->no_plan(); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
8
|
|
|
|
|
26
|
for my $test (@$data){ |
126
|
15
|
|
|
|
|
873
|
$test->run_tests(); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Scott McWhirter, C<< >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Copyright 2007 Scott McWhirter, all rights reserved. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This program is released under the following license: BSD. Please see the |
139
|
|
|
|
|
|
|
LICENSE file included in this distribution for details. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |