1Plack::Middleware::TestU:s:eSrtaCsohnWtarrinbiuntgesdP(l3Pa)ecrkl::DMoicdudmleenwtaartei:o:nTest::StashWarnings(3)
2
3
4

NAME

6       Plack::Middleware::Test::StashWarnings - Test your application's
7       warnings
8

SYNOPSIS

10         # for your PSGI application:
11         enable "Test::StashWarnings";
12
13
14         # for your Test::WWW::Mechanize subclass:
15         use Storable 'thaw';
16         sub get_warnings {
17             local $Test::Builder::Level = $Test::Builder::Level + 1;
18             my $self = shift;
19
20             my $clone = $self->clone;
21             return unless $clone->get_ok('/__test_warnings');
22
23             my @warnings = @{ thaw $clone->content };
24             return @warnings;
25         }
26

DESCRIPTION

28       Plack::Middleware::Test::StashWarnings is a Plack middleware component
29       to record warnings generated by your application so that you can test
30       them to make sure your application complains about the right things.
31
32       The warnings generated by your application are available at a special
33       URL ("/__test_warnings"), encoded with "nfreeze" in Storable. So using
34       Test::WWW::Mechanize you can just "get" that URL and "thaw" in Storable
35       its content.
36

ARGUMENTS

38       Plack::Middleware::Test::StashWarnings takes one optional argument,
39       "verbose", which defaults to $ENV{TEST_VERBOSE}.  If set to true, it
40       will bubble warnings up to any pre-existing "__WARN__" handler.
41       Turning this explicitly off may be useful if your tests load
42       Test::NoWarnings and also use Test::WWW::Mechanize::PSGI for non-
43       forking testing -- failure to do so would result in test failures even
44       for caught warnings.
45

RATIONALE

47       Warnings are an important part of any application. Your web application
48       should warn its operators when something is amiss.
49
50       Almost as importantly, your web application should gracefully cope with
51       bad input, the back button, and all other aspects of the user
52       experience.
53
54       Unfortunately, tests seldom cover what happens when things go poorly.
55       Are you sure that your application correctly denies that action and
56       logs the failure? Are you sure it will tomorrow?
57
58       This module lets you retrieve the warnings that your forked server
59       issues. That way you can test that your application continues to issue
60       warnings when it makes sense. Catching the warnings also keeps your
61       test output tidy. Finally, you'll be able to see (and be notified via
62       failing tests) when your application issues new, unexpected warnings so
63       you can fix them immediately.
64

AUTHOR

66       Shawn M Moore "sartak@bestpractical.com"
67
68       Tatsuhiko Miyagawa wrote Plack::Middleware::Test::Recorder which served
69       as a model for this module.
70

LICENSE

72       This library is free software; you can redistribute it and/or modify it
73       under the same terms as Perl itself.
74

SEE ALSO

76       Test::HTTP::Server::Simple::StashWarnings
77
78
79
80perl v5.32.0                      2020P-l0a7c-k2:8:Middleware::Test::StashWarnings(3)
Impressum