strip old $Id tags
[bioperl-live.git] / t / lib / Test / Harness / Results.pm
blobf972fdd8161e85b61b9a1c34dd1342c5b0af30fa
1 # -*- Mode: cperl; cperl-indent-level: 4 -*-
2 package Test::Harness::Results;
4 use strict;
5 use vars qw($VERSION);
6 $VERSION = '0.01';
8 =head1 NAME
10 Test::Harness::Results - object for tracking results from a single test file
12 =head1 SYNOPSIS
14 One Test::Harness::Results object represents the results from one
15 test file getting analyzed.
17 =head1 CONSTRUCTION
19 =head2 new()
21 my $results = new Test::Harness::Results;
23 Create a test point object. Typically, however, you'll not create
24 one yourself, but access a Results object returned to you by
25 Test::Harness::Results.
27 =cut
29 sub new {
30 my $class = shift;
31 my $self = bless {}, $class;
33 return $self;
36 =head1 ACCESSORS
38 The following data points are defined:
40 passing true if the whole test is considered a pass
41 (or skipped), false if its a failure
43 exit the exit code of the test run, if from a file
44 wait the wait code of the test run, if from a file
46 max total tests which should have been run
47 seen total tests actually seen
48 skip_all if the whole test was skipped, this will
49 contain the reason.
51 ok number of tests which passed
52 (including todo and skips)
54 todo number of todo tests seen
55 bonus number of todo tests which
56 unexpectedly passed
58 skip number of tests skipped
60 So a successful test should have max == seen == ok.
63 There is one final item, the details.
65 details an array ref reporting the result of
66 each test looks like this:
68 $results{details}[$test_num - 1] =
69 { ok => is the test considered ok?
70 actual_ok => did it literally say 'ok'?
71 name => name of the test (if any)
72 diagnostics => test diagnostics (if any)
73 type => 'skip' or 'todo' (if any)
74 reason => reason for the above (if any)
77 Element 0 of the details is test #1. I tried it with element 1 being
78 #1 and 0 being empty, this is less awkward.
81 Each of the following fields has a getter and setter method.
83 =over 4
85 =item * wait
87 =item * exit
89 =cut
91 sub set_wait { my $self = shift; $self->{wait} = shift }
92 sub wait {
93 my $self = shift;
94 return $self->{wait} || 0;
97 sub set_skip_all { my $self = shift; $self->{skip_all} = shift }
98 sub skip_all {
99 my $self = shift;
100 return $self->{skip_all};
103 sub inc_max { my $self = shift; $self->{max} += (@_ ? shift : 1) }
104 sub max {
105 my $self = shift;
106 return $self->{max} || 0;
109 sub set_passing { my $self = shift; $self->{passing} = shift }
110 sub passing {
111 my $self = shift;
112 return $self->{passing} || 0;
115 sub inc_ok { my $self = shift; $self->{ok} += (@_ ? shift : 1) }
116 sub ok {
117 my $self = shift;
118 return $self->{ok} || 0;
121 sub set_exit { my $self = shift; $self->{exit} = shift }
122 sub exit {
123 my $self = shift;
124 return $self->{exit} || 0;
127 sub inc_bonus { my $self = shift; $self->{bonus}++ }
128 sub bonus {
129 my $self = shift;
130 return $self->{bonus} || 0;
133 sub set_skip_reason { my $self = shift; $self->{skip_reason} = shift }
134 sub skip_reason {
135 my $self = shift;
136 return $self->{skip_reason} || 0;
139 sub inc_skip { my $self = shift; $self->{skip}++ }
140 sub skip {
141 my $self = shift;
142 return $self->{skip} || 0;
145 sub inc_todo { my $self = shift; $self->{todo}++ }
146 sub todo {
147 my $self = shift;
148 return $self->{todo} || 0;
151 sub inc_seen { my $self = shift; $self->{seen}++ }
152 sub seen {
153 my $self = shift;
154 return $self->{seen} || 0;
157 sub set_details {
158 my $self = shift;
159 my $index = shift;
160 my $details = shift;
162 my $array = ($self->{details} ||= []);
163 $array->[$index-1] = $details;
166 sub details {
167 my $self = shift;
168 return $self->{details} || [];