App::Yath::Tester(3pm) | User Contributed Perl Documentation | App::Yath::Tester(3pm) |
App::Yath::Tester - Tools for testing yath
This package provides utilities for running yath from within tests to verify its behavior. This is primarily used for integration testing of yath and for third party components.
use App::Yath::Tester qw/yath/; my $result = yath( # Command and arguments command => 'test', args => ['-pMyPlugin', 'path/to/test', ...], # Exit code we expect from yath exit => 0, # Subtest to verify results test => sub { my $result = shift; # Redundant since we have the exit check above is($result->{exit}, 0, "Verify exit"); is($result->{output}, $expected_output, "Got the expected output from yath"); }, );
There are 2 exports from this module.
my $result = yath( # Command and arguments command => 'test', args => ['-pMyPlugin', 'path/to/test', ...], # Exit code we expect from yath exit => 0, # Subtest to verify results test => sub { my $result = shift; # Redundant since we have the exit check above is($result->{exit}, 0, "Verify exit"); is($result->{output}, $expected_output, "Got the expected output from yath"); }, );
ARGUMENTS
$ yath [PRE_COMMAND] [COMMAND] [ARGS]
$ yath [PRE_COMMAND] [COMMAND] [ARGS]
test => sub { my $result = shift; ... verify result ... },
0 - No debugging 1 - Output the command and other action being taken by the tool 2 - Echo yath output as it happens
When true the tool will look for a directory next to your test file with an identical name except that '.t' or '.t2' will be stripped from it. If that directory exists it will be added as a dev-lib to the yath command.
If your test file is 't/foo/bar.t' then your yath command will look like this:
$ yath -D=t/foo/bar [PRE-COMMAND] [COMMAND] [ARGS]
When true the yath output will be captured and put into "$result->{output}".
When true yath will be instructed to produce a log, the log will be accessible via "$result->{log}". "$result->{log}" will be an instance of Test2::Harness::Util::File::JSONL.
Normally "-D=/path/to/lib" is added to the yath command where '/path/to/lib' is the path the the lib dir App::Yath was loaded from. This normally insures the correct version of yath libraries is loaded.
When this argument is set to true the path is not added.
perl [LIB] path/to/yath [PRE-COMMAND] [COMMAND] [ARGS]
RESULT
The result hashref may containt he following fields depending on the arguments passed into "yath()".
Note: By default no logging is done, you must specify the "log => 1" argument to enable it.
This will create a temporary directory with 't', 't2', and 'xt' subdirectories each of which will contain a single passing test.
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
Copyright 2020 Chad Granum <exodist7@gmail.com>.
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/
2023-10-04 | perl v5.36.0 |