1Test2::Formatter(3)   User Contributed Perl Documentation  Test2::Formatter(3)
2
3
4

NAME

6       Test2::Formatter - Namespace for formatters.
7

DESCRIPTION

9       This is the namespace for formatters. This is an empty package.
10

CREATING FORMATTERS

12       A formatter is any package or object with a "write($event, $num)"
13       method.
14
15           package Test2::Formatter::Foo;
16           use strict;
17           use warnings;
18
19           sub write {
20               my $self_or_class = shift;
21               my ($event, $assert_num) = @_;
22               ...
23           }
24
25           sub hide_buffered { 1 }
26
27           sub terminate { }
28
29           sub finalize { }
30
31           sub new_root {
32               my $class = shift;
33               ...
34               $class->new(@_);
35           }
36
37           1;
38
39       The "write" method is a method, so it either gets a class or instance.
40       The two arguments are the $event object it should record, and the
41       $assert_num which is the number of the current assertion (ok), or the
42       last assertion if this event is not itself an assertion. The assertion
43       number may be any integer 0 or greater, and may be undefined in some
44       cases.
45
46       The "hide_buffered()" method must return a boolean. This is used to
47       tell buffered subtests whether or not to send it events as they are
48       being buffered.  See "run_subtest(...)" in Test2::API for more
49       information.
50
51       The "terminate" and "finalize" methods are optional methods called that
52       you can implement if the format you're generating needs to handle these
53       cases, for example if you are generating XML and need close open tags.
54
55       The "terminate" method is called when an event's "terminate" method
56       returns true, for example when a Test2::Event::Plan has a 'skip_all'
57       plan, or when a Test2::Event::Bail event is sent. The "terminate"
58       method is passed a single argument, the Test2::Event object which
59       triggered the terminate.
60
61       The "finalize" method is always the last thing called on the formatter,
62       except when "terminate" is called for a Bail event. It is passed the
63       following arguments:
64
65       The "new_root" method is called when "Test2::API::Stack" Initializes
66       the root hub for the first time. Most formatters will simply have this
67       call "$class->new", which is the default behavior. Some formatters
68       however may want to take extra action during construction of the root
69       formatter, this is where they can do that.
70
71       ·   The number of tests that were planned
72
73       ·   The number of tests actually seen
74
75       ·   The number of tests which failed
76
77       ·   A boolean indicating whether or not the test suite passed
78
79       ·   A boolean indicating whether or not this call is for a subtest
80

SOURCE

82       The source code repository for Test2 can be found at
83       http://github.com/Test-More/test-more/.
84

MAINTAINERS

86       Chad Granum <exodist@cpan.org>
87

AUTHORS

89       Chad Granum <exodist@cpan.org>
90
92       Copyright 2018 Chad Granum <exodist@cpan.org>.
93
94       This program is free software; you can redistribute it and/or modify it
95       under the same terms as Perl itself.
96
97       See http://dev.perl.org/licenses/
98
99
100
101perl v5.28.0                      2018-08-13               Test2::Formatter(3)
Impressum