NAME
Test::Builder2::History - Manage the history of test results
SYNOPSIS
use Test::Builder2::History;
my $history = Test::Builder2::History->new;
my $result = Test::Builder2::Result->new_result( pass => 1 );
$history->accept_result( $result, $ec );
$history->is_passing;
DESCRIPTION
This object stores and manages the history of test results.
METHODS
Constructors
new
my $history = Test::Builder2::History->new;
Creates a new, unique History object.
Accessors
Unless otherwise stated, these are all accessor methods of the form:
my $value = $history->method; # get
$history->method($value); # set
Events
events
A Test::Builder2::Stack of events, that include Result objects.
accept_event
Push an event to the events stack.
event_count
Get the count of events that are on the stack.
Results
results
A Test::Builder2::Stack of Result objects.
# The result of test #4.
my $result = $history->results->[3];
accept_result
Add a result object to the end stack,
result_count
Get the count of results stored in the stack.
NOTE: This could be diffrent from the number of tests that have been seen, to get that count use test_count.
has_results
Returns true if we have stored results, false otherwise.
Statistics
test_count
A count of the number of tests that have been added to results. This value is not guaranteed to be the same as results_count if you have altered the results_stack. This is a static counter of the number of tests that have been seen, not the number of results stored.
pass_count
A count of the number of passed tests have been added to results.
fail_count
A count of the number of failed tests have been added to results.
todo_count
A count of the number of TODO tests have been added to results.
skip_count
A count of the number of SKIP tests have been added to results.
is_passing
Returns true if we have not yet seen a failing test.
plan
my $plan = $history->plan;
Returns the plan event for the current stream, if any.
State
History tracks some basic information about the state of the test surmised by watching the events go by.
stream_depth
my $stream_depth = $history->stream_depth;
Returns how many stream start
events without stream end
events have been seen.
For example...
stream start
Would indicate a level of 1.
stream start
stream start
stream end
stream start
Would indicate a level of 2.
A value of 0 indiciates the Formatter is not in a stream.
A negative value will throw an exception.
HISTORY INTERACTION
consume
$history->consume($old_history);
Appends $old_history results in to $history's results stack.