| Test2::Manual::Tooling::Formatter(3) | Perl Programmers Reference Guide | Test2::Manual::Tooling::Formatter(3) |
Test2::Manual::Tooling::Formatter - How to write a custom formatter, in our case a JSONL formatter.
This tutorial explains a minimal formatter that outputs each event as a json string on its own line. A true formatter will probably be significantly more complicated, but this will give you the basics needed to get started.
package Test2::Formatter::MyFormatter;
use strict;
use warnings;
use JSON::MaybeXS qw/encode_json/;
use base qw/Test2::Formatter/;
sub new { bless {}, shift }
sub encoding {};
sub write {
my ($self, $e, $num, $f) = @_;
$f ||= $e->facet_data;
print encode_json($f), "\n";
}
1;
Test2::Manual - Primary index of the manual.
The source code repository for Test2-Manual can be found at https://github.com/Test-More/Test2-Suite/.
Copyright 2018 Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
| 2025-03-30 | perl v5.40.2 |