NAME
Test::Builder2::History - Manage the history of test results
SYNOPSIS
use Test::Builder2::History;
# This is a shared singleton object
my $history = Test::Builder2::History->singleton;
my $result = Test::Builder2::Result->new_result( pass => 1 );
$history->accept_result( $result );
$history->is_passing;
DESCRIPTION
This object stores and manages the history of test results.
METHODS
Constructors
singleton
my $history = Test::Builder2::History->singleton;
Test::Builder2::History->singleton($history);
Gets/sets the shared instance of the history object.
Test::Builder2::History is a singleton. singleton() will return the same object every time so all users can have a shared history. If you want your own history, call create() instead.
create
my $history = Test::Builder2::History->create;
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.
HISTORY INTERACTION
consume
$history->consume($old_history);
Appends $old_history results in to $history's results stack.