1Test::Able(3) User Contributed Perl Documentation Test::Able(3)
2
3
4
6 Test::Able - xUnit with Moose
7
9 0.10
10
12 package MyTest;
13
14 use Test::Able;
15 use Test::More;
16
17 startup some_startup => sub { ... };
18 setup some_setup => sub { ... };
19 test plan => 1, foo => sub { ok( 1 ); };
20 test bar => sub {
21 my @runtime_list = 1 .. 42;
22 $_[ 0 ]->meta->current_method->plan( scalar @runtime_list );
23 ok( 1 ) for @runtime_list;
24 };
25 teardown some_teardown => sub { ... };
26 shutdown some_shutdown => sub { ... };
27
28 MyTest->run_tests;
29
31 An xUnit style testing framework inspired by Test::Class and built
32 using Moose. It can do all the important things Test::Class can do and
33 more. The prime advantages of using this module instead of Test::Class
34 are flexibility and power. Namely, Moose.
35
36 This module was created for a few of reasons:
37
38 • To address perceived limitations in, and downfalls of, Test::Class.
39
40 • To leverage existing Moose expertise for testing.
41
42 • To bring Moose to the Perl testing game.
43
45 In addition to exporting for Moose, Test::Able will export a handful of
46 functions that can be used to declare test-related methods.
47
48 startup/setup/test/teardown/shutdown
49 A more Moose-like way to do method declaration. The syntax is
50 similar to "has" in Moose except its for test-related methods.
51
52 These start with one of startup/setup/test/teardown/shutdown
53 depending on what type of method you are defining. Then comes any
54 attribute name/value pairs to set in the
55 Test::Able::Role::Meta::Method-based method metaclass object. The
56 last pair must always be the method name and the coderef. This is
57 to disambiguate between the method name/code pair and any another
58 attribute in the method metaclass that happens to take a coderef.
59 See the synopsis or the tests for examples.
60
62 1. Build some test classes: a, b, & c. The classes just have to be
63 based on Test::Able.
64
65 2. Fire up an instance of any of them to be the runner object. Any
66 test object can serve as the test_runner_object including itself.
67
68 my $b_obj = b->new;
69
70 3. Setup the test_objects in the test_runner_object.
71
72 $b_obj->test_objects( [
73 a->new,
74 $b_obj,
75 c->new,
76 ] );
77
78 4. Do the test run. The test_objects will be run in order.
79
80 $b_obj->run_tests;
81
83 Test::Able::Cookbook
84 support
85 #moose on irc.perl.org
86
87 code
88 http://github.com/jdv/test-able/tree/master
89
90 Moose
91 Test::Class
92 Test::Builder
93
95 Justin DeVuyst, "justin@devuyst.com"
96
98 Copyright 2009 by Justin DeVuyst.
99
100 This library is free software, you can redistribute it and/or modify it
101 under the same terms as Perl itself.
102
103
104
105perl v5.36.0 2023-01-20 Test::Able(3)