1Test::Stream::Plugin::CUosreer(3C)ontributed Perl DocumeTnetsatt:i:oSntream::Plugin::Core(3)
2
3
4

NAME

6       Test::Stream::Plugin::Core - Test::Stream implementation of the core
7       testing tools.
8

DEPRECATED

10       This distribution is deprecated in favor of Test2, Test2::Suite, and
11       Test2::Workflow.
12
13       See Test::Stream::Manual::ToTest2 for a conversion guide.
14

DESCRIPTION

16       This is not a drop-in replacement for Test::More.
17
18       The new Testing library to replace Test::More. This library is directly
19       built on new internals instead of Test::Builder.
20
21       This module implements most of the same functionality as Test::More,
22       but since changing to this library from Test::More is not automatic,
23       some incompatible API changes have been made. If you decide to replace
24       Test::More in existing test files, you may have to update some function
25       calls.
26

SYNOPSIS

28           use Test::Stream qw/Core/;
29
30           set_encoding('utf8');
31
32           plan($num); # Optional, set a plan
33
34           use Data::Dumper;
35           imported_ok qw/Dumper/;
36           not_imported_ok qw/dumper/;
37
38           # skip all tests in some condition
39           skip_all("do not run") if $cond;
40
41           if ($passing) {
42               pass('a passing test');
43           }
44           else {
45               fail('a failing test');
46           }
47
48           ok($x, "simple test");
49
50           # Check that the class or object has the specified methods defined.
51           can_ok($class_or_obj, @methods);
52
53           # Check that the class or object is or subclasses the specified packages
54           isa_ok($class_or_obj, @packages);
55
56           # Check that the class or object consumes the specified roles.
57           DOES_ok($class_or_obj, @roles);
58
59           # Check that $ref is a HASH reference
60           ref_ok($ref, 'HASH', 'Must be a hash')
61
62           # The preferred way to plan
63           done_testing;
64

EXPORTS

66       All subs are exported by default.
67
68   ASSERTIONS
69       ok($bool)
70       ok($bool, $name)
71       ok($bool, $name, @diag)
72           Simple assertion. If $bool is true the test passes, if it is false
73           the test fails. The test name is optional, and all arguments after
74           the name are added as diagnostics message if and only if the test
75           fails. If the test passes all the diagnostics arguments will be
76           ignored.
77
78       pass()
79       pass($name)
80           Fire off a passing test (a single Ok event). The name is optional
81
82       fail()
83       fail($name)
84       fail($name, @diag)
85           Fire off a failing test (a single Ok event). The name and
86           diagnostics are optional.
87
88       imported_ok(@SUB_NAMES)
89           Check that the specified subs have been defined in the current
90           namespace. This will NOT find inherited subs, the subs must be in
91           the current namespace.
92
93       not_imported_ok(@SUB_NAMES)
94           Check that the specified subs have NOT been defined in the current
95           namespace.  This will NOT find inherited subs, the subs must be in
96           the current namespace.
97
98       can_ok($thing, @methods)
99           This checks that $thing (either a class name, or a blessed
100           instance) has the specified methods.
101
102       isa_ok($thing, @classes)
103           This checks that $thing (either a class name, or a blessed
104           instance) is or subclasses the specified classes.
105
106       DOES_ok($thing, @roles)
107           This checks that $thing (either a class name, or a blessed
108           instance) does the specified roles.
109
110       ref_ok($thing)
111       ref_ok($thing, $type)
112       ref_ok($thing, $type, $name)
113           This checks that $thing is a reference. If $type is specified then
114           it will check that $thing is that type of reference.
115
116       ref_is($ref1, $ref2, $name)
117           Verify that 2 references are the exact same reference.
118
119       ref_is_not($ref1, $ref2, $name)
120           Verify that 2 references are not the exact same reference.
121
122       cmp_ok($got, $op, $expect)
123       cmp_ok($got, $op, $expect, $name)
124       cmp_ok($got, $op, $expect, $name, @diag)
125           Compare $got to $expect using the operator specified in $op. This
126           is effectively a "eval "\$got $op \$expect"" with some other stuff
127           to make it more sane. This is useful for comparing numbers,
128           overloaded objects, etc.
129
130           Overloading Note: Your input is passed as-is to the comparison. In
131           the event that the comparison fails between 2 overloaded objects,
132           the diagnostics will try to show you the overload form that was
133           used in comparisons. It is possible that the diagnostics will be
134           wrong, though attempts have been made to improve them since
135           Test::More.
136
137           Exceptions: If the comparison results in an exception then the test
138           will fail and the exception will be shown.
139
140           cmp_ok has an internal list of operators it supports. If you
141           provide an unsupported operator it will issue a warning. You can
142           add operators to the %Test::Stream::Plugin::Core::OPS hash, the key
143           should be the operator, and the value should either be 'str' for
144           string comparison operators, 'num' for numeric operators, or any
145           other true value for other operators.
146
147           Supported operators:
148
149           ==  (num)
150           !=  (num)
151           >=  (num)
152           <=  (num)
153           >   (num)
154           <   (num)
155           <=> (num)
156           eq  (str)
157           ne  (str)
158           gt  (str)
159           lt  (str)
160           ge  (str)
161           le  (str)
162           cmp (str)
163           !~  (str)
164           =~  (str)
165           &&
166           ||
167           xor
168           or
169           and
170           //
171           &
172           |
173           ~~
174
175   DIAGNOSTICS
176       diag(@messages)
177           Write diagnostics messages. All items in @messages will be joined
178           into a single string with no seperator. When using TAP diagnostics
179           are sent to STDERR.
180
181       note(@messages)
182           Write note-diagnostics messages. All items in @messages will be
183           joined into a single string with no seperator. When using TAP note-
184           diagnostics are sent to STDOUT.
185
186   PLANNING
187       plan($num)
188           Set the number of tests that are expected. This must be done first
189           or last, never in the middle of testing.
190
191       skip_all($reason)
192           Set the plan to 0 with a reason, then exit true. This should be
193           used before any tests are run.
194
195       done_testing
196           Used to mark the end of testing. This is a safe way to have a
197           dynamic or unknown number of tests.
198
199       BAIL_OUT($reason)
200           Something has gone horribly wrong, stop everything, kill all
201           threads and processes, end the process with a false exit status.
202
203   META
204       $todo = todo($reason)
205       todo $reason => sub { ... }
206           This is used to mark some results as TODO. TODO means that the test
207           may fail, but will not cause the overall test suite to fail.
208
209           There are 2 ways to use this, the first is to use a codeblock, the
210           TODO will only apply to the codeblock.
211
212               ok(1, "before"); # Not TODO
213
214               todo 'this will fail' => sub {
215                   # This is TODO, as is any other test in this block.
216                   ok(0, "blah");
217               };
218
219               ok(1, "after"); # Not TODO
220
221           The other way is to use a scoped variable, TODO will end when the
222           variable is destroyed or set to undef.
223
224               ok(1, "before"); # Not TODO
225
226               {
227                   my $todo = todo 'this will fail';
228
229                   # This is TODO, as is any other test in this block.
230                   ok(0, "blah");
231               };
232
233               ok(1, "after"); # Not TODO
234
235           This is the same thing, but without the "{...}" scope.
236
237               ok(1, "before"); # Not TODO
238
239               my $todo = todo 'this will fail';
240
241               ok(0, "blah"); # TODO
242
243               $todo = undef;
244
245               ok(1, "after"); # Not TODO
246
247       skip($why)
248       skip($why, $count)
249           This is used to skip some tests. This requires you to wrap your
250           tests in a block labeled "SKIP:", this is somewhat magical. If no
251           $count is specified then it will issue a single result. If you
252           specify $count it will issue that many results.
253
254               SKIP: {
255                   skip "This will wipe your drive";
256
257                   # This never gets run:
258                   ok(!system('sudo rm -rf /'), "Wipe drive");
259               }
260
261       set_encoding($encoding)
262           This will set the encoding to whatever you specify. This will only
263           effect the output of the current formatter, which is usually your
264           TAP output formatter.
265

SEE ALSO

267       Test::Stream::Plugin::Subtest
268           Subtest support
269
270       Test::Stream::Plugin::Intercept
271           Tools for intercepting events, exceptions, warnings, etc.
272
273       Test::Stream::Bundle::Tester
274           Tools for testing your test tools
275
276       Test::Stream::Plugin::IPC
277           Use this module directly for more control over concurrency.
278

SOURCE

280       The source code repository for Test::Stream can be found at
281       http://github.com/Test-More/Test-Stream/.
282

MAINTAINERS

284       Chad Granum <exodist@cpan.org>
285

AUTHORS

287       Chad Granum <exodist@cpan.org>
288
290       Copyright 2015 Chad Granum <exodist7@gmail.com>.
291
292       This program is free software; you can redistribute it and/or modify it
293       under the same terms as Perl itself.
294
295       See http://dev.perl.org/licenses/
296
297
298
299perl v5.28.0                      2016-02-05     Test::Stream::Plugin::Core(3)
Impressum