Class: Test::Mini::Logger
- Inherits:
-
Object
- Object
- Test::Mini::Logger
- Defined in:
- lib/Test/Mini/Logger.pm
Overview
Output Logger Base Class.
Whether you’re using a tool that expects output in a certain format, or you just long for the familiar look and feel of another testing framework, this is what you’re looking for.
Direct Known Subclasses
Defined Under Namespace
Classes: TAP
Attribute Accessors (collapse)
-
- (IO) buffer($self)
Output buffer.
-
- verbose($self)
Logger verbosity.
Output Functions (collapse)
-
- print($self, @msg)
Write output to the #buffer.
-
- say($self, @msg)
Write output to the #buffer.
Callbacks (collapse)
-
- begin_test($self, $tc, $test)
Called before each test is run.
-
- begin_test_case($self, $tc, @tests)
Called before each test case is run.
-
- begin_test_suite($self, %args)
Called before the test suite is run.
-
- error($self, $tc, $test, $e)
Called when a test dies with an error.
-
- fail($self, $tc, $test, $e)
Called when a test fails.
-
- finish_test($self, $tc, $test, $assertions)
Called after each test is run.
-
- finish_test_case($self, $tc, @tests)
Called after each test case is run.
-
- finish_test_suite($self, $exit_code)
Called after each test suite is run.
-
- pass($self, $tc, $test)
Called when a test passes.
-
- skip($self, $tc, $test, $e)
Called when a test is skipped.
Statistics (collapse)
-
- count($self, $key)
Accessor for counters.
-
- (Number) time($self, $key)
Accessor for the timing data.
Class Method Summary (collapse)
-
+ new($class, %args)
Constructor.
Class Method Details
+ new($class, %args)
Constructor.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/Test/Mini/Logger.pm', line 17 sub new { my ($class, %args) = @_; return bless { verbose => 0, buffer => *STDOUT{IO}, %args, count => {}, times => {}, }, $class; } |
Instance Method Details
- begin_test($self, $tc, $test)
Called before each test is run.
88 89 90 91 |
# File 'lib/Test/Mini/Logger.pm', line 88 sub begin_test { my ($self, $tc, $test) = @_; $self->{times}->{"$tc#$test"} = -Time::HiRes::time(); } |
- begin_test_case($self, $tc, @tests)
Called before each test case is run.
79 80 81 82 |
# File 'lib/Test/Mini/Logger.pm', line 79 sub begin_test_case { my ($self, $tc, @tests) = @_; $self->{times}->{$tc} = -Time::HiRes::time(); } |
- begin_test_suite($self, %args)
Called before the test suite is run.
70 71 72 73 |
# File 'lib/Test/Mini/Logger.pm', line 70 sub begin_test_suite { my ($self, %args) = @_; $self->{times}->{$self} = -Time::HiRes::time(); } |
- (IO) buffer($self)
Output buffer.
37 38 39 40 |
# File 'lib/Test/Mini/Logger.pm', line 37 sub buffer { my ($self) = @_; return $self->{buffer}; } |
- (Hash) count - (Number) count($key)
Accessor for counters.
179 180 181 182 |
# File 'lib/Test/Mini/Logger.pm', line 179 sub count { my ($self, $key) = @_; return ($key ? $self->{count}->{$key} : $self->{count}) || 0; } |
- error($self, $tc, $test, $e)
Called when a test dies with an error. Increments the error count.
164 165 166 167 |
# File 'lib/Test/Mini/Logger.pm', line 164 sub error { my ($self, $tc, $test, $e) = @_; $self->{count}->{error}++; } |
- fail($self, $tc, $test, $e)
Called when a test fails. Increments the failure count.
153 154 155 156 |
# File 'lib/Test/Mini/Logger.pm', line 153 sub fail { my ($self, $tc, $test, $e) = @_; $self->{count}->{fail}++; } |
- finish_test($self, $tc, $test, $assertions)
Called after each test is run. Increments the test and assertion counts, and finalizes the test’s timing.
99 100 101 102 103 104 |
# File 'lib/Test/Mini/Logger.pm', line 99 sub finish_test { my ($self, $tc, $test, $assertions) = @_; $self->{count}->{test}++; $self->{count}->{assert} += $assertions; $self->{times}->{"$tc#$test"} += Time::HiRes::time(); } |
- finish_test_case($self, $tc, @tests)
Called after each test case is run. Increments the test case count, and finalizes the test case’s timing.
111 112 113 114 115 |
# File 'lib/Test/Mini/Logger.pm', line 111 sub finish_test_case { my ($self, $tc, @tests) = @_; $self->{count}->{test_case}++; $self->{times}->{$tc} += Time::HiRes::time(); } |
- finish_test_suite($self, $exit_code)
Called after each test suite is run. Finalizes the test suite timing.
121 122 123 124 |
# File 'lib/Test/Mini/Logger.pm', line 121 sub finish_test_suite { my ($self, $exit_code) = @_; $self->{times}->{$self} += Time::HiRes::time(); } |
- pass($self, $tc, $test)
Called when a test passes. Increments the pass count.
131 132 133 134 |
# File 'lib/Test/Mini/Logger.pm', line 131 sub pass { my ($self, $tc, $test) = @_; $self->{count}->{pass}++; } |
- print($self, @msg)
Write output to the #buffer. Lines will be output without added newlines.
48 49 50 51 |
# File 'lib/Test/Mini/Logger.pm', line 48 sub print { my ($self, @msg) = @_; print { $self->buffer() } @msg; } |
- say($self, @msg)
Write output to the #buffer. Lines will be output with appended newlines.
58 59 60 61 |
# File 'lib/Test/Mini/Logger.pm', line 58 sub say { my ($self, @msg) = @_; $self->print(join("\n", @msg), "\n"); } |
- skip($self, $tc, $test, $e)
Called when a test is skipped. Increments the skip count.
142 143 144 145 |
# File 'lib/Test/Mini/Logger.pm', line 142 sub skip { my ($self, $tc, $test, $e) = @_; $self->{count}->{skip}++; } |
- (Number) time($self, $key)
Accessor for the timing data.
192 193 194 195 |
# File 'lib/Test/Mini/Logger.pm', line 192 sub time { my ($self, $key) = @_; return $self->{times}->{$key}; } |
- verbose($self)
Logger verbosity.
31 32 33 34 |
# File 'lib/Test/Mini/Logger.pm', line 31 sub verbose { my ($self) = @_; return $self->{verbose}; } |