1Test2::Suite(3) User Contributed Perl Documentation Test2::Suite(3)
2
3
4
6 Test2::Suite - Distribution with a rich set of tools built upon the
7 Test2 framework.
8
10 Rich set of tools, plugins, bundles, etc built upon the Test2 testing
11 library. If you are interested in writing tests, this is the
12 distribution for you.
13
14 WHAT ARE TOOLS, PLUGINS, AND BUNDLES?
15 TOOLS
16 Tools are packages that export functions for use in test files.
17 These functions typically generate events. Tools SHOULD NEVER alter
18 behavior of other tools, or the system in general.
19
20 PLUGINS
21 Plugins are packages that produce effects, or alter behavior of
22 tools. An example would be a plugin that causes the test to bail
23 out after the first failure. Plugins SHOULD NOT export anything.
24
25 BUNDLES
26 Bundles are collections of tools and plugins. A bundle should load
27 and re-export functions from Tool packages. A bundle may also load
28 and configure any number of plugins.
29
30 If you want to write something that both exports new functions, and
31 effects behavior, you should write both a Tools distribution, and a
32 Plugin distribution, then a Bundle that loads them both. This is
33 important as it helps avoid the problem where a package exports much-
34 desired tools, but also produces undesirable side effects.
35
37 Test2::V#
38 These do not live in the bundle namespace as they are the primary
39 ways to use Test2::Suite.
40
41 The current latest is Test2::V0.
42
43 use Test2::V0;
44 # strict and warnings are on for you now.
45
46 ok(...);
47
48 # Note: is does deep checking, unlike the 'is' from Test::More.
49 is(...);
50
51 ...
52
53 done_testing;
54
55 This bundle includes every tool listed in the "INCLUDED TOOLS"
56 section below, except for Test2::Tools::ClassicCompare. This bundle
57 provides most of what anyone writing tests could need. This is also
58 the preferred bundle/toolset of the Test2 author.
59
60 See Test2::V0 for complete documentation.
61
62 Extended
63 ** Deprecated ** See Test2::V0
64
65 use Test2::Bundle::Extended;
66 # strict and warnings are on for you now.
67
68 ok(...);
69
70 # Note: is does deep checking, unlike the 'is' from Test::More.
71 is(...);
72
73 ...
74
75 done_testing;
76
77 This bundle includes every tool listed in the "INCLUDED TOOLS"
78 section below, except for Test2::Tools::ClassicCompare. This bundle
79 provides most of what anyone writing tests could need. This is also
80 the preferred bundle/toolset of the Test2 author.
81
82 See Test2::Bundle::Extended for complete documentation.
83
84 More
85 use Test2::Bundle::More;
86 use strict;
87 use warnings;
88
89 plan 3; # Or you can use done_testing at the end
90
91 ok(...);
92
93 is(...); # Note: String compare
94
95 is_deeply(...);
96
97 ...
98
99 done_testing; # Use instead of plan
100
101 This bundle is meant to be a mostly drop-in replacement for
102 Test::More. There are some notable differences to be aware of
103 however. Some exports are missing: "eq_array", "eq_hash", "eq_set",
104 $TODO, "explain", "use_ok", "require_ok". As well it is no longer
105 possible to set the plan at import: "use .. tests => 5". $TODO has
106 been replaced by the "todo()" function. Planning is done using
107 "plan", "skip_all", or "done_testing".
108
109 See Test2::Bundle::More for complete documentation.
110
111 Simple
112 use Test2::Bundle::Simple;
113 use strict;
114 use warnings;
115
116 plan 1;
117
118 ok(...);
119
120 This bundle is meant to be a mostly drop-in replacement for
121 Test::Simple. See Test2::Bundle::Simple for complete
122 documentation.
123
125 Basic
126 Basic provides most of the essential tools previously found in
127 Test::More. However it does not export any tools used for
128 comparison. The basic "pass", "fail", "ok" functions are present,
129 as are functions for planning.
130
131 See Test2::Tools::Basic for complete documentation.
132
133 Compare
134 This provides "is", "like", "isnt", "unlike", and several
135 additional helpers. Note: These are all deep comparison tools and
136 work like a combination of Test::More's "is" and "is_deeply".
137
138 See Test2::Tools::Compare for complete documentation.
139
140 ClassicCompare
141 This provides Test::More flavored "is", "like", "isnt", "unlike",
142 and "is_deeply". It also provides "cmp_ok".
143
144 See Test2::Tools::ClassicCompare for complete documentation.
145
146 Class
147 This provides functions for testing objects and classes, things
148 like "isa_ok".
149
150 See Test2::Tools::Class for complete documentation.
151
152 Defer
153 This provides functions for writing test functions in one place,
154 but running them later. This is useful for testing things that run
155 in an altered state.
156
157 See Test2::Tools::Defer for complete documentation.
158
159 Encoding
160 This exports a single function that can be used to change the
161 encoding of all your test output.
162
163 See Test2::Tools::Encoding for complete documentation.
164
165 Exports
166 This provides tools for verifying exports. You can verify that
167 functions have been imported, or that they have not been imported.
168
169 See Test2::Tools::Exports for complete documentation.
170
171 Mock
172 This provides tools for mocking objects and classes. This is based
173 largely on Mock::Quick, but several interface improvements have
174 been added that cannot be added to Mock::Quick itself without
175 breaking backwards compatibility.
176
177 See Test2::Tools::Mock for complete documentation.
178
179 Ref This exports tools for validating and comparing references.
180
181 See Test2::Tools::Ref for complete documentation.
182
183 Spec
184 This is an RSPEC implementation with concurrency support.
185
186 See Test2::Tools::Spec for more details.
187
188 Subtest
189 This exports tools for running subtests.
190
191 See Test2::Tools::Subtest for complete documentation.
192
193 Target
194 This lets you load the package(s) you intend to test, and alias
195 them into constants/package variables.
196
197 See Test2::Tools::Target for complete documentation.
198
200 BailOnFail
201 The much requested "bail-out on first failure" plugin. When this
202 plugin is loaded, any failure will cause the test to bail out
203 immediately.
204
205 See Test2::Plugin::BailOnFail for complete documentation.
206
207 DieOnFail
208 The much requested "die on first failure" plugin. When this plugin
209 is loaded, any failure will cause the test to die immediately.
210
211 See Test2::Plugin::DieOnFail for complete documentation.
212
213 ExitSummary
214 This plugin gives you statistics and diagnostics at the end of your
215 test in the event of a failure.
216
217 See Test2::Plugin::ExitSummary for complete documentation.
218
219 SRand
220 Use this to set the random seed to a specific seed, or to the
221 current date.
222
223 See Test2::Plugin::SRand for complete documentation.
224
225 UTF8
226 Turn on utf8 for your testing. This sets the current file to be
227 utf8, it also sets STDERR, STDOUT, and your formatter to all output
228 utf8.
229
230 See Test2::Plugin::UTF8 for complete documentation.
231
233 AuthorTesting
234 Using this package will cause the test file to be skipped unless
235 the AUTHOR_TESTING environment variable is set.
236
237 See Test2::Require::AuthorTesting for complete documentation.
238
239 EnvVar
240 Using this package will cause the test file to be skipped unless a
241 custom environment variable is set.
242
243 See Test2::Require::EnvVar for complete documentation.
244
245 Fork
246 Using this package will cause the test file to be skipped unless
247 the system is capable of forking (including emulated forking).
248
249 See Test2::Require::Fork for complete documentation.
250
251 RealFork
252 Using this package will cause the test file to be skipped unless
253 the system is capable of true forking.
254
255 See Test2::Require::RealFork for complete documentation.
256
257 Module
258 Using this package will cause the test file to be skipped unless
259 the specified module is installed (and optionally at a minimum
260 version).
261
262 See Test2::Require::Module for complete documentation.
263
264 Perl
265 Using this package will cause the test file to be skipped unless
266 the specified minimum perl version is met.
267
268 See Test2::Require::Perl for complete documentation.
269
270 Threads
271 Using this package will cause the test file to be skipped unless
272 the system has threading enabled.
273
274 Note: This will not turn threading on for you.
275
276 See Test2::Require::Threads for complete documentation.
277
279 See the Test2 documentation for a namespace map. Everything in this
280 distribution uses Test2.
281
282 Test2::Manual is the Test2 Manual.
283
285 Many Test2 developers and users lurk on <irc://irc.perl.org/#perl>. We
286 also have a slack team that can be joined by anyone with an "@cpan.org"
287 email address <https://perl-test2.slack.com/> If you do not have an
288 "@cpan.org" email you can ask for a slack invite by emailing Chad
289 Granum <exodist@cpan.org>.
290
292 The source code repository for Test2-Suite can be found at
293 https://github.com/Test-More/Test2-Suite/.
294
296 Chad Granum <exodist@cpan.org>
297
299 Chad Granum <exodist@cpan.org>
300
302 Copyright 2018 Chad Granum <exodist@cpan.org>.
303
304 This program is free software; you can redistribute it and/or modify it
305 under the same terms as Perl itself.
306
307 See http://dev.perl.org/licenses/
308
309
310
311perl v5.30.1 2020-01-31 Test2::Suite(3)