• Home
  • History
  • Annotate
  • only in this directory
NameDateSize

..11-Apr-2013244

ChangesH A D20-Feb-20133.2 KiB

lib/H05-Apr-20133

LICENSEH A D20-Feb-201325.9 KiB

Makefile.PLH A D20-Feb-20131.3 KiB

MANIFESTH A D20-Feb-2013407

META.jsonH A D20-Feb-20131.1 KiB

META.ymlH A D20-Feb-2013629

MYMETA.jsonH A D20-Feb-20131.1 KiB

READMEH A D20-Feb-20135.1 KiB

t/H11-Apr-20138

xt/H11-Apr-20135

README

1NAME
2    Test::NoWarnings - Make sure you didn't emit any warnings while testing
3
4SYNOPSIS
5    For scripts that have no plan
6
7      use Test::NoWarnings;
8
9    that's it, you don't need to do anything else
10
11    For scripts that look like
12
13      use Test::More tests => x;
14
15    change to
16
17      use Test::More tests => x + 1;
18      use Test::NoWarnings;
19
20DESCRIPTION
21    In general, your tests shouldn't produce warnings. This modules causes
22    any warnings to be captured and stored. It automatically adds an extra
23    test that will run when your script ends to check that there were no
24    warnings. If there were any warings, the test will give a "not ok" and
25    diagnostics of where, when and what the warning was, including a stack
26    trace of what was going on when the it occurred.
27
28    If some of your tests are supposed to produce warnings then you should
29    be capturing and checking them with Test::Warn, that way
30    Test::NoWarnings will not see them and so not complain.
31
32    The test is run by an "END" block in Test::NoWarnings. It will not be
33    run when any forked children exit.
34
35USAGE
36    Simply by using the module, you automatically get an extra test at the
37    end of your script that checks that no warnings were emitted. So just
38    stick
39
40      use Test::NoWarnings;
41
42    at the top of your script and continue as normal.
43
44    If you want more control you can invoke the test manually at any time
45    with "had_no_warnings".
46
47    The warnings your test has generated so far are stored in an array. You
48    can look inside and clear this whenever you want with "warnings()" and
49    "clear_warnings", however, if you are doing this sort of thing then you
50    probably want to use Test::Warn in combination with Test::NoWarnings.
51
52  use vs require
53    You will almost always want to do
54
55      use Test::NoWarnings
56
57    If you do a "require" rather than a "use", then there will be no
58    automatic test at the end of your script.
59
60  Output
61    If warning is captured during your test then the details will output as
62    part of the diagnostics. You will get:
63
64    o the number and name of the test that was executed just before the
65      warning (if no test had been executed these will be 0 and '')
66
67    o the message passed to "warn",
68
69    o a full dump of the stack when warn was called, courtesy of the "Carp"
70      module
71
72    By default, all warning messages will be emitted in one block at the end
73    of your test script.
74
75  The :early pragma
76    One common complaint from people using Test::NoWarnings is that all of
77    the warnings are emitted in one go at the end. While this is the safest
78    and most correct time to emit these diagnostics, it can make debugging
79    these warnings difficult.
80
81    As of Test::NoWarnings 1.04 you can provide an experimental ":early"
82    pragma when loading the module to force warnings to be thrown via diag
83    at the time that they actually occur.
84
85      use Test::NoWarnings ':early';
86
87    As this will cause the diag to be emitted against the previous test and
88    not the one in which the warning actually occurred it is recommended
89    that the pragma be turned on only for debugging and left off when not
90    needed.
91
92FUNCTIONS
93  had_no_warnings
94    This checks that there have been warnings emitted by your test scripts.
95    Usually you will not call this explicitly as it is called automatically
96    when your script finishes.
97
98  clear_warnings
99    This will clear the array of warnings that have been captured. If the
100    array is empty then a call to "had_no_warnings()" will produce a pass
101    result.
102
103  warnings
104    This will return the array of warnings captured so far. Each element of
105    this array is an object containing information about the warning. The
106    following methods are available on these object.
107
108    * $warn->getMessage
109
110      Get the message that would been printed by the warning.
111
112    * $warn->getCarp
113
114      Get a stack trace of what was going on when the warning happened, this
115      stack trace is just a string generated by the Carp module.
116
117    * $warn->getTrace
118
119      Get a stack trace object generated by the Devel::StackTrace module.
120      This will return undef if Devel::StackTrace is not installed.
121
122    * $warn->getTest
123
124      Get the number of the test that executed before the warning was
125      emitted.
126
127    * $warn->getTestName
128
129      Get the name of the test that executed before the warning was emitted.
130
131PITFALLS
132    When counting your tests for the plan, don't forget to include the test
133    that runs automatically when your script ends.
134
135SUPPORT
136    Bugs should be reported via the CPAN bug tracker at
137
138    <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-NoWarnings>
139
140    For other issues, contact the author.
141
142HISTORY
143    This was previously known as Test::Warn::None
144
145SEE ALSO
146    Test::Builder, Test::Warn
147
148AUTHORS
149    Fergal Daly <fergal@esatclear.ie>
150
151    Adam Kennedy <adamk@cpan.org>
152
153COPYRIGHT
154    Copyright 2003 - 2007 Fergal Daly.
155
156    Some parts copyright 2010 - 2011 Adam Kennedy.
157
158    This program is free software and comes with no warranty. It is
159    distributed under the LGPL license
160
161    See the file LGPL included in this distribution or
162    http://www.fsf.org/licenses/licenses.html.
163
164