Test2::V0(3)
๐ Test2::V0(3) โ User Contributed Perl Documentation, bestie ๐
๐ธ NAME ๐ธ
Test2::V0 โ 0Th edition of the Test2 recommended bundle. Periodt. ๐
๐ฆ DESCRIPTION ๐ฆ
Okay so this is the big-daddy bundle. It includes nearly every tool, and several plugins, that the Test2 author uses. This bundle is used extensively to test Test2::Suite itself. It's giving main character energy fr fr. ๐
๐ง NAMING, USING, DEPENDING ๐ง
This bundle should not change in a severely incompatible way. Some minor breaking changes โ specially bugfixes โ may be allowed. If breaking changes are needed then a new Test2::V# module should be released instead.
As new V# modules are released old ones may be moved to different cpan distributions. You should always use a specific bundle version and list that version in your distributions testing requirements. You should never simply list Test2::Suite as your modules dep, instead list the specific bundle, or tools and plugins you use directly in your metadata. No cap, that's the move. ๐ซถ
โจ SYNOPSIS โจ
use Test2::V0;
ok(1, "pass");
...
done_testing;
๐ฆ RESOLVING CONFLICTS WITH MOOSE ๐ฆ
use Test2::V0 '!meta';
Moose and Test2::V0 both export very different meta() subs. Adding '!meta' to the import args will prevent the sub from being imported. This bundle also exports the sub under the name meta_check() so you can use that spelling as an alternative. Slay. โจ
๐ท๏ธ TAGS ๐ท๏ธ
:DEFAULT
The following are both identical:
use Test2::V0;
use Test2::V0 ':DEFAULT';
๐ท๏ธ RENAMING ON IMPORT ๐ท๏ธ
use Test2::V0 ':DEFAULT', '!ok', ok => {-as => 'my_ok'};
This bundle uses Test2::Util::Importer for exporting, as such you can use any arguments it accepts.
Explanation:
'!ok'โ Do not exportok()ok => {-as => 'my_ok'}โ Actually, go ahead and importok()but under the namemy_ok().
If you did not add the '!ok' argument then you would have both ok() and my_ok(). Iykyk. ๐
๐ PRAGMAS ๐
All of these can be disabled via individual import arguments, or by the -no_pragmas argument.
use Test2::V0 -no_pragmas => 1;
๐ช STRICT ๐ช
strict is turned on for you. You can disable this with the -no_strict or -no_pragmas import arguments:
use Test2::V0 -no_strict => 1;
โ ๏ธ WARNINGS โ ๏ธ
warnings are turned on for you. You can disable this with the -no_warnings or -no_pragmas import arguments:
use Test2::V0 -no_warnings => 1;
๐ UTF8 ๐
This is actually done via the Test2::Plugin::UTF8 plugin, see the "PLUGINS" section for details.
Note: -no_pragmas => 1 will turn off the entire plugin. ๐
๐ PLUGINS ๐
๐ฒ SRAND ๐ฒ
See Test2::Plugin::SRand.
This will set the random seed to today's date. You can provide an alternate seed with the -srand import option:
use Test2::V0 -srand => 1234;
You can also disable this behavior:
use Test2::V0 -no_srand => 1;
Note: Whensrandis on (default) it can cause problems with things likeFile::Tempwhich will end up attempting the same "random" filenames for every test process started on a given day (or sharing the same seed). Not me warning you, the manual is warning you ๐ญ
๐ UTF8 ๐
See Test2::Plugin::UTF8.
This will set the file, and all output handles (including formatter handles), to utf8. This will turn on the utf8 pragma for the current scope.
This can be disabled using the -no_utf8 => 1 or -no_pragmas => 1 import arguments.
use Test2::V0 -no_utf8 => 1;
๐ช EXIT SUMMARY ๐ช
See Test2::Plugin::ExitSummary.
This plugin has no configuration. Simple. Clean. Iconic. โจ
๐ ENVIRONMENT VARIABLES ๐
See Test2::Env for a list of meaningul environment variables.
โก API FUNCTIONS โก
See Test2::API for these:
$ctx = context()
$events = intercept { ... }
๐ ๏ธ TOOLS ๐ ๏ธ
๐ฏ TARGET ๐ฏ
See Test2::Tools::Target.
You can specify a target class with the -target import argument. If you do not provide a target then $CLASS and CLASS() will not be imported.
use Test2::V0 -target => 'My::Class';
print $CLASS; # My::Class
print CLASS(); # My::Class
Or you can specify names:
use Test2::V0 -target => { pkg => 'Some::Package' };
pkg()->xxx; # Call 'xxx' on Some::Package
$pkg->xxx; # Same
$CLASSโ Package variable that contains the target class name.$class = CLASS()โ Constant function that returns the target class name.
โณ DEFER โณ
See Test2::Tools::Defer.
def $func => @args;
do_def()
๐งฑ BASIC ๐งฑ
See Test2::Tools::Basic.
ok($bool, $name)
ok($bool, $name, @diag)
pass($name)
pass($name, @diag)
fail($name)
fail($name, @diag)
diag($message)
note($message)
$todo = todo($reason)
todo $reason => sub { ... }
skip($reason, $count)
plan($count)
skip_all($reason)
done_testing()
bail_out($reason)
๐งฎ COMPARE ๐งฎ
See Test2::Tools::Compare.
is($got, $want, $name)
isnt($got, $do_not_want, $name)
like($got, qr/match/, $name)
unlike($got, qr/mismatch/, $name)
$check = match(qr/pattern/)
$check = mismatch(qr/pattern/)
$check = validator(sub { return $bool })
$check = hash { ... }
$check = array { ... }
$check = bag { ... }
$check = object { ... }
$check = meta { ... }
$check = number($num)
$check = string($str)
$check = bool($bool)
$check = check_isa($class_name)
$check = in_set(@things)
$check = not_in_set(@things)
$check = check_set(@things)
$check = item($thing)
$check = item($idx => $thing)
$check = field($name => $val)
$check = call($method => $expect)
$check = call_list($method => $expect)
$check = call_hash($method => $expect)
$check = prop($name => $expect)
$check = check($thing)
$check = T()
$check = F()
$check = D()
$check = DF()
$check = E()
$check = DNE()
$check = FDNE()
$check = U()
$check = L()
$check = exact_ref($ref)
end()
etc()
filter_items { grep { ... } @_ }
$check = event $type => ...
@checks = fail_events $type => ...
๐งฎ CLASSIC COMPARE ๐งฎ
See Test2::Tools::ClassicCompare.
cmp_ok($got, $op, $want, $name)
๐งช SUBTEST ๐งช
See Test2::Tools::Subtest.
subtest $name => sub { ... };
Note: This is called subtest_buffered() in the Tools module.
๐งฌ CLASS ๐งฌ
See Test2::Tools::Class.
can_ok($thing, @methods)
isa_ok($thing, @classes)
DOES_ok($thing, @roles)
๐ค ENCODING ๐ค
See Test2::Tools::Encoding.
set_encoding($encoding)
๐ฆ EXPORTS ๐ฆ
See Test2::Tools::Exports.
imported_ok('function', '$scalar', ...)
not_imported_ok('function', '$scalar', ...)
๐ REF ๐
See Test2::Tools::Ref.
ref_ok($ref, $type)
ref_is($got, $want)
ref_is_not($got, $do_not_want)
See Test2::Tools::Refcount.
is_refcount($ref, $count, $description)
is_oneref($ref, $description)
$count = refcount($ref)
๐ญ MOCK ๐ญ
See Test2::Tools::Mock.
$control = mock ...
$bool = mocked($thing)
๐ฅ EXCEPTION ๐ฅ
See Test2::Tools::Exception.
$exception = dies { ... }
$bool = lives { ... }
$bool = try_ok { ... }
โ ๏ธ WARNINGS โ ๏ธ
See Test2::Tools::Warnings.
$count = warns { ... }
$warning = warning { ... }
$warnings_ref = warnings { ... }
$bool = no_warnings { ... }
๐ SOURCE ๐
The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/.
๐ MAINTAINERS ๐
Chad Granum <exodist@cpan.org>
โ๏ธ AUTHORS โ๏ธ
Chad Granum <exodist@cpan.org>
ยฉ๏ธ COPYRIGHT ยฉ๏ธ
Copyright Chad Granum <exodist@cpan.org>.
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/
๐ซถ That's the manual, bestie โperl v5.42.0on2025-07-28. Go forth and test slayfully. ๐โจ
๐ฆ where this page comes from
- opensuse-leap 16.0: perl-Test-Simple 1.302214-bp160.1.2 ยท Artistic-1.0 OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms