1Test2::Harness::Plugin(U3s)er Contributed Perl DocumentatTieosnt2::Harness::Plugin(3)
2
3
4

NAME

6       Test2::Harness::Plugin - Base class for Test2::Harness plugins.
7

DESCRIPTION

9       This class holds the methods specific to Test2::Harness which is the
10       backend. Most of the time you actually want to subclass
11       App::Yath::Plugin which subclasses this class, and holds additional
12       methods that apply to yath (the UI layer).
13

SYNOPSIS

15       You probably want to subclass App::Yath::Plugin instead. This class
16       here mainly exists to separate concerns, but is not something you
17       should use directly.
18
19           package Test2::Harness::Plugin::MyPlugin;
20
21           use parent 'Test2::Harness::Plugin';
22
23           # ... Define methods
24
25           1;
26

METHODS

28       $plugin->munge_search($input, $default_search, $settings)
29           $input is an arrayref of files and/or directories provided at the
30           command line.
31
32           $default_search is an arrayref with the default files/directories
33           pulled in when nothing is specified at the command ine.
34
35           $settings is an instance of Test2::Harness::Settings
36
37       $undef_or_inst = $plugin->claim_file($path, $settings)
38           This is a chance for a plugin to claim a test file early, before
39           Test2::Harness takes care of it. If your plugin does not want to
40           claim the file just return undef. To claim the file return an
41           instance of Test2::Harness::TestFile created with $path.
42
43       $plugin->munge_files(\@tests, $settings)
44           This is an opportunity for your plugin to modify the data for any
45           test file that will be run. The first argument is an arrayref of
46           Test2::Harness::TestFile objects.
47
48       $plugin->inject_run_data(meta => $meta, fields => $fields, run => $run)
49           This is a callback that lets your plugin add meta-data or custom
50           fields to the run event. The meta-data and fields are available in
51           the event log, and are particularily useful to App::Yath::UI.
52
53               sub inject_run_data {
54                   my $class  = shift;
55                   my %params = @_;
56
57                   my $meta   = $params{meta};
58                   my $fields = $params{fields};
59
60                   # Meta-data is a hash, each plugin should define its own key, and put
61                   # data under that key
62                   $meta->{MyPlugin}->{stuff} = "Stuff!";
63
64                   # Fields is an array of fields that a UI might want to display when showing the run.
65                   push @$fields => {name => 'MyPlugin', details => "Human Friendly Stuff", raw => "Less human friendly stuff", data => $all_the_stuff};
66
67                   return;
68               }
69
70       $plugin->setup($settings)
71           This is a callback that lets you run setup logic when the runner
72           starts. Note that in a persistent runner this is run once on
73           startup, it is not run for each "run" command against the
74           persistent runner.
75
76       $plugin->teardown($settings)
77           This is a callback that lets you run teardown logic when the runner
78           stops. Note that in a persistent runner this is run once on
79           termination, it is not run for each "run" command against the
80           persistent runner.
81
82       $plugin->TO_JSON
83           This is here as a bare minimum serialization method. It returns the
84           plugin class name.
85

SOURCE

87       The source code repository for Test2-Harness can be found at
88       http://github.com/Test-More/Test2-Harness/.
89

MAINTAINERS

91       Chad Granum <exodist@cpan.org>
92

AUTHORS

94       Chad Granum <exodist@cpan.org>
95
97       Copyright 2020 Chad Granum <exodist7@gmail.com>.
98
99       This program is free software; you can redistribute it and/or modify it
100       under the same terms as Perl itself.
101
102       See http://dev.perl.org/licenses/
103
104
105
106perl v5.32.0                      2020-07-28         Test2::Harness::Plugin(3)
Impressum