1TAP::Parser::Aggregator(P3eprml)Programmers Reference GTuAiPd:e:Parser::Aggregator(3pm)
2
3
4
6 TAP::Parser::Aggregator - Aggregate TAP::Parser results
7
9 Version 3.17
10
12 use TAP::Parser::Aggregator;
13
14 my $aggregate = TAP::Parser::Aggregator->new;
15 $aggregate->add( 't/00-load.t', $load_parser );
16 $aggregate->add( 't/10-lex.t', $lex_parser );
17
18 my $summary = <<'END_SUMMARY';
19 Passed: %s
20 Failed: %s
21 Unexpectedly succeeded: %s
22 END_SUMMARY
23 printf $summary,
24 scalar $aggregate->passed,
25 scalar $aggregate->failed,
26 scalar $aggregate->todo_passed;
27
29 "TAP::Parser::Aggregator" collects parser objects and allows
30 reporting/querying their aggregate results.
31
33 Class Methods
34 "new"
35
36 my $aggregate = TAP::Parser::Aggregator->new;
37
38 Returns a new "TAP::Parser::Aggregator" object.
39
40 Instance Methods
41 "add"
42
43 $aggregate->add( $description => $parser );
44
45 The $description is usually a test file name (but only by convention.)
46 It is used as a unique identifier (see e.g. "parsers".) Reusing a
47 description is a fatal error.
48
49 The $parser is a TAP::Parser object.
50
51 "parsers"
52
53 my $count = $aggregate->parsers;
54 my @parsers = $aggregate->parsers;
55 my @parsers = $aggregate->parsers(@descriptions);
56
57 In scalar context without arguments, this method returns the number of
58 parsers aggregated. In list context without arguments, returns the
59 parsers in the order they were added.
60
61 If @descriptions is given, these correspond to the keys used in each
62 call to the add() method. Returns an array of the requested parsers
63 (in the requested order) in list context or an array reference in
64 scalar context.
65
66 Requesting an unknown identifier is a fatal error.
67
68 "descriptions"
69
70 Get an array of descriptions in the order in which they were added to
71 the aggregator.
72
73 "start"
74
75 Call "start" immediately before adding any results to the aggregator.
76 Among other times it records the start time for the test run.
77
78 "stop"
79
80 Call "stop" immediately after adding all test results to the
81 aggregator.
82
83 "elapsed"
84
85 Elapsed returns a Benchmark object that represents the running time of
86 the aggregated tests. In order for "elapsed" to be valid you must call
87 "start" before running the tests and "stop" immediately afterwards.
88
89 "elapsed_timestr"
90
91 Returns a formatted string representing the runtime returned by
92 "elapsed()". This lets the caller not worry about Benchmark.
93
94 "all_passed"
95
96 Return true if all the tests passed and no parse errors were detected.
97
98 "get_status"
99
100 Get a single word describing the status of the aggregated tests.
101 Depending on the outcome of the tests returns 'PASS', 'FAIL' or
102 'NOTESTS'. This token is understood by CPAN::Reporter.
103
104 Summary methods
105 Each of the following methods will return the total number of
106 corresponding tests if called in scalar context. If called in list
107 context, returns the descriptions of the parsers which contain the
108 corresponding tests (see "add" for an explanation of description.
109
110 · failed
111
112 · parse_errors
113
114 · passed
115
116 · planned
117
118 · skipped
119
120 · todo
121
122 · todo_passed
123
124 · wait
125
126 · exit
127
128 For example, to find out how many tests unexpectedly succeeded (TODO
129 tests which passed when they shouldn't):
130
131 my $count = $aggregate->todo_passed;
132 my @descriptions = $aggregate->todo_passed;
133
134 Note that "wait" and "exit" are the totals of the wait and exit
135 statuses of each of the tests. These values are totalled only to
136 provide a true value if any of them are non-zero.
137
138 "total"
139
140 my $tests_run = $aggregate->total;
141
142 Returns the total number of tests run.
143
144 "has_problems"
145
146 if ( $parser->has_problems ) {
147 ...
148 }
149
150 Identical to "has_errors", but also returns true if any TODO tests
151 unexpectedly succeeded. This is more akin to "warnings".
152
153 "has_errors"
154
155 if ( $parser->has_errors ) {
156 ...
157 }
158
159 Returns true if any of the parsers failed. This includes:
160
161 · Failed tests
162
163 · Parse errors
164
165 · Bad exit or wait status
166
167 "todo_failed"
168
169 # deprecated in favor of 'todo_passed'. This method was horribly misnamed.
170
171 This was a badly misnamed method. It indicates which TODO tests
172 unexpectedly succeeded. Will now issue a warning and call
173 "todo_passed".
174
176 TAP::Parser
177
178 TAP::Harness
179
180
181
182perl v5.12.4 2011-06-07 TAP::Parser::Aggregator(3pm)