The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

TB2::Counter - Counts the number of tests run

SYNOPSIS

  use TB2::Counter;

  my $counter = TB2::Counter->new;

  $counter->increment;
  $counter->set($count);
  $counter->get;

DESCRIPTION

This object simply contains the count of the number of tests run as a simple positive integer.

Most testing systems don't care how many tests run, but this is very important for TAP output.

The counter is normally used through TB2::History, but you can get it separately if you want to be really slim.

METHODS

Constructors

new

    my $counter = TB2::Counter->new;

Creates a brand new counter starting at 0.

The Count

increment

    my $count = $counter->increment;
    my $count = $counter->increment($amount);

Increments the counter by $amount or 1 if $amount is not given.

Returns the new $count.

Like ++$count.

set

    my $count_was = $counter->set($count);

Sets the counter to $count.

Return what the $count_was.

get

    my $count = $counter->get;

Gets the $count.