1Test2::Tools::Class(3)User Contributed Perl DocumentationTest2::Tools::Class(3)
2
3
4
6 Test2::Tools::Class - Test2 implementation of the tools for testing
7 classes.
8
10 Test2 based tools for validating classes and objects. These are similar
11 to some tools from Test::More, but they have a more consistent
12 interface.
13
15 use Test2::Tools::Class;
16
17 isa_ok($CLASS_OR_INSTANCE, $PARENT_CLASS1, $PARENT_CLASS2, ...);
18 isa_ok($CLASS_OR_INSTANCE, [$PARENT_CLASS1, $PARENT_CLASS2, ...], "Test Name");
19
20 can_ok($CLASS_OR_INSTANCE, $METHOD1, $METHOD2, ...);
21 can_ok($CLASS_OR_INSTANCE, [$METHOD1, $METHOD2, ...], "Test Name");
22
23 DOES_ok($CLASS_OR_INSTANCE, $ROLE1, $ROLE2, ...);
24 DOES_ok($CLASS_OR_INSTANCE, [$ROLE1, $ROLE2, ...], "Test Name");
25
27 All subs are exported by default.
28
29 can_ok($thing, @methods)
30 can_ok($thing, \@methods, $test_name)
31 This checks that $thing (either a class name, or a blessed
32 instance) has the specified methods.
33
34 If the second argument is an arrayref then it will be used as the
35 list of methods leaving the third argument to be the test name.
36
37 isa_ok($thing, @classes)
38 isa_ok($thing, \@classes, $test_name)
39 This checks that $thing (either a class name, or a blessed
40 instance) is or subclasses the specified classes.
41
42 If the second argument is an arrayref then it will be used as the
43 list of classes leaving the third argument to be the test name.
44
45 DOES_ok($thing, @roles)
46 DOES_ok($thing, \@roles, $test_name)
47 This checks that $thing (either a class name, or a blessed
48 instance) does the specified roles.
49
50 If the second argument is an arrayref then it will be used as the
51 list of roles leaving the third argument to be the test name.
52
53 Note 1: This uses the "$class->DOES(...)" method, not the "does()"
54 method Moose provides.
55
56 Note 2: Not all perls have the "DOES()" method, if you use this on
57 those perls the test will be skipped.
58
60 The source code repository for Test2-Suite can be found at
61 https://github.com/Test-More/Test2-Suite/.
62
64 Chad Granum <exodist@cpan.org>
65
67 Chad Granum <exodist@cpan.org>
68
70 Copyright 2018 Chad Granum <exodist@cpan.org>.
71
72 This program is free software; you can redistribute it and/or modify it
73 under the same terms as Perl itself.
74
75 See http://dev.perl.org/licenses/
76
77
78
79perl v5.30.0 2019-07-26 Test2::Tools::Class(3)