@@ -281,8 +281,8 @@ __END__
281
281
282
282
=head1 DESCRIPTION
283
283
284
- See the L<Test::Class::Moose home page|http://houseabsolute.github.io/test-class-moose/> for
285
- a summary.
284
+ See the L<Test::Class::Moose home
285
+ page|http://houseabsolute.github.io/test-class-moose/> for a summary.
286
286
287
287
C<Test::Class::Moose > is a powerful testing framework for Perl. Out of the box
288
288
you get:
@@ -318,15 +318,15 @@ Just C<use Test::Class::Moose>. That's all. You'll get all L<Test::Most> test
318
318
functions, too, along with C<strict > and C<warnings > . You can use all L<Moose>
319
319
behavior, too.
320
320
321
- When you C<use Test::Class::Moose > it inserts itself as a parent class for
322
- your test class. This means that if you try to use C<extends > in your test
323
- class you will break things unless you include C<Test::Class::Moose > as a
324
- parent. We recommend that you use roles in your test classes instead.
321
+ When you C<use Test::Class::Moose > it inserts itself as a parent class for your
322
+ test class. This means that if you try to use C<extends > in your test class you
323
+ will break things unless you include C<Test::Class::Moose > as a parent. We
324
+ recommend that you use roles in your test classes instead.
325
325
326
326
=head2 Declare a test method
327
327
328
- All method names that begin with C<test_ > are test methods. Methods that do
329
- not are not test methods.
328
+ All method names that begin with C<test_ > are test methods. Methods that do not
329
+ are not test methods.
330
330
331
331
sub test_this_is_a_method {
332
332
my $test = shift;
@@ -341,8 +341,8 @@ not are not test methods.
341
341
}
342
342
343
343
You may specify C<Test > and C<Tests > method attributes, just like in
344
- L<Test::Class> and the method will automatically be a test method, even if
345
- does not start with C<test_ > :
344
+ L<Test::Class> and the method will automatically be a test method, even if does
345
+ not start with C<test_ > :
346
346
347
347
sub this_is_a_test : Test {
348
348
pass 'we have a single test';
@@ -393,9 +393,9 @@ method modifier:
393
393
# more tests
394
394
};
395
395
396
- Please note that if you call C<plan > , the plan will still show up at the end
397
- of the subtest run, but you'll get the desired failure if the number of tests
398
- run does not match the plan.
396
+ Please note that if you call C<plan > , the plan will still show up at the end of
397
+ the subtest run, but you'll get the desired failure if the number of tests run
398
+ does not match the plan.
399
399
400
400
=head2 Inheriting from another Test::Class::Moose class
401
401
@@ -511,13 +511,13 @@ The available test control methods are:
511
511
}
512
512
513
513
Runs at the start of each test class. Quite often the base class that you
514
- inherit from will have its own C<test_startup > code running (such as starting
515
- a database transaction or connecting to an external resource). You almost
516
- always want to call C<< $test->next::method >> I<before > your own setup code.
517
- This ensures that the environment is set up to safely run your code. For
518
- example, if the parent C<test_startup > starts a database transaction with the
519
- expectation that the C<test_teardown > will end the database transactions, you
520
- can safely load database fixtures I<after > that is run.
514
+ inherit from will have its own C<test_startup > code running (such as starting a
515
+ database transaction or connecting to an external resource). You almost always
516
+ want to call C<< $test->next::method >> I<before > your own setup code. This
517
+ ensures that the environment is set up to safely run your code. For example, if
518
+ the parent C<test_startup > starts a database transaction with the expectation
519
+ that the C<test_teardown > will end the database transactions, you can safely
520
+ load database fixtures I<after > that is run.
521
521
522
522
If you need to know the name of the class you're running this in (though
523
523
usually you shouldn't), use C<< $test->test_class >>, or you can do this:
@@ -530,8 +530,8 @@ usually you shouldn't), use C<< $test->test_class >>, or you can do this:
530
530
...
531
531
}
532
532
533
- The C<< $test->test_report >> object is a L<Test::Class::Moose::Report::Instance>
534
- object.
533
+ The C<< $test->test_report >> object is a
534
+ L<Test::Class::Moose::Report::Instance> object.
535
535
536
536
=head2 C<test_setup >
537
537
@@ -598,10 +598,10 @@ can tell the L<Test::Class::Moose::Runner> to create multiple instances of a
598
598
test class.
599
599
600
600
To do this, simply consume the
601
- L<Test::Class::Moose::Role::ParameterizedInstances> role in your test
602
- class. This role requires you to implement a C<_constructor_parameter_sets >
603
- method in your test class. That method will be called as a I<class method > . It
604
- is expected to return a list of key/value pairs. The keys are the name of the
601
+ L<Test::Class::Moose::Role::ParameterizedInstances> role in your test class.
602
+ This role requires you to implement a C<_constructor_parameter_sets > method in
603
+ your test class. That method will be called as a I<class method > . It is
604
+ expected to return a list of key/value pairs. The keys are the name of the
605
605
instance and the values are hashrefs of attributes to be passed to your test
606
606
class's constructor. Here's a really dumb example:
607
607
@@ -630,15 +630,15 @@ instance>, and each instance will be run in its own subtest. You can
630
630
dynamically decide to skip your test class completely by having
631
631
C<_constructor_parameter_sets > return an empty list.
632
632
633
- Note that this feature has great potential for abuse, so use it
634
- cautiously. That said, there are cases where this feature can greatly simplify
635
- your test code.
633
+ Note that this feature has great potential for abuse, so use it cautiously.
634
+ That said, there are cases where this feature can greatly simplify your test
635
+ code.
636
636
637
637
=head1 RUNNING THE TEST SUITE
638
638
639
- See the docs for L<Test::Class::Moose::Runner> for details on running your
640
- test suite. If you'd like to get up and running quickly, here's a very simple
641
- test file you can use:
639
+ See the docs for L<Test::Class::Moose::Runner> for details on running your test
640
+ suite. If you'd like to get up and running quickly, here's a very simple test
641
+ file you can use:
642
642
643
643
use Test::Class::Moose::CLI;
644
644
Test::Class::Moose::CLI->new_with_options->run;
@@ -658,9 +658,9 @@ If you wish to skip a class, set the reason in the C<test_startup> method.
658
658
$test->test_skip("I don't want to run this class");
659
659
}
660
660
661
- If you are using L<test class instances|/"TEST CLASS INSTANCES"> , you
662
- can also make C<_constructor_parameter_sets > return an empty list,
663
- which will result in the class being skipped.
661
+ If you are using L<test class instances|/"TEST CLASS INSTANCES"> , you can also
662
+ make C<_constructor_parameter_sets > return an empty list, which will result in
663
+ the class being skipped.
664
664
665
665
Note that if you run C<test_skip > , the C<test_shutdown > method will also be
666
666
skipped. This is due to the assumption that you might not have run any setup
@@ -683,11 +683,11 @@ If you wish to skip an individual method, do so in the C<test_setup> method.
683
683
684
684
=head2 The "Tests" and "Test" Attributes
685
685
686
- If you're comfortable with L<Test::Class> , you know that test methods methods are
687
- declared in L<Test::Class> with C<Test > (for a method with a single test) or
688
- C<Tests > , for a method with multiple tests. This also works for
689
- C<Test::Class::Moose > . Test methods declared this way do not need to start
690
- with C<test_ > .
686
+ If you're comfortable with L<Test::Class> , you know that test methods methods
687
+ are declared in L<Test::Class> with C<Test > (for a method with a single test)
688
+ or C<Tests > , for a method with multiple tests. This also works for
689
+ C<Test::Class::Moose > . Test methods declared this way do not need to start with
690
+ C<test_ > .
691
691
692
692
sub something_we_want_to_check : Test {
693
693
# this method may have only one test
@@ -725,22 +725,22 @@ And later:
725
725
}
726
726
727
727
In the above example, C<TestsFor::Parent::some_test > will run three tests, but
728
- C<TestsFor::Child::some_test > will run I<five > tests (two tests, plus the
729
- three from the parent).
728
+ C<TestsFor::Child::some_test > will run I<five > tests (two tests, plus the three
729
+ from the parent).
730
730
731
- Note that if a plan is explicitly declared, any modifiers or overriding
732
- methods calling the original method will also have to assert the number of
733
- tests to ensure the plan is correct. The above C<TestsFor::Parent > and
734
- C<TestsFor::Child > code would fail if the child's C<some_test > method
735
- attribute was C<Tests > without the number of tests asserted.
731
+ Note that if a plan is explicitly declared, any modifiers or overriding methods
732
+ calling the original method will also have to assert the number of tests to
733
+ ensure the plan is correct. The above C<TestsFor::Parent > and
734
+ C<TestsFor::Child > code would fail if the child's C<some_test > method attribute
735
+ was C<Tests > without the number of tests asserted.
736
736
737
737
Do not use C<Test > or C<Tests > with test control methods because you don't run
738
738
tests in those.
739
739
740
740
=head2 Tagging Methods
741
741
742
- Sometimes you want to be able to assign metadata to help you better manage
743
- your test suite. You can do this with tags:
742
+ Sometimes you want to be able to assign metadata to help you better manage your
743
+ test suite. You can do this with tags:
744
744
745
745
sub test_save_poll_data : Tags(api network) {
746
746
...
@@ -782,19 +782,20 @@ optional. Now it's mandatory, so those features should always work.
782
782
... but probably shouldn't.
783
783
784
784
As a general rule, methods beginning with C</^test_/ > are reserved for
785
- L<Test::Class::Moose> . This makes it easier to remember what you can and
786
- cannot override. However, any test with C<Test > or C<Tests > are test methods
785
+ L<Test::Class::Moose> . This makes it easier to remember what you can and cannot
786
+ override. However, any test with C<Test > or C<Tests > are test methods
787
787
regardless of their names.
788
788
789
789
=head2 C<test_report >
790
790
791
791
my $report = $test->test_report;
792
792
793
- Returns the L<Test::Class::Moose::Report> object. Useful if you want to do
794
- your own reporting and not rely on the default output provided with the
793
+ Returns the L<Test::Class::Moose::Report> object. Useful if you want to do your
794
+ own reporting and not rely on the default output provided with the
795
795
C<statistics > boolean option.
796
796
797
- You can also call it in test classes (most useful in the C<test_setup() > method):
797
+ You can also call it in test classes (most useful in the C<test_setup() >
798
+ method):
798
799
799
800
sub test_setup {
800
801
my $test = shift;
@@ -960,9 +961,9 @@ for you, see L<Test::Class::Moose::Role::AutoUse> in this distribution.
960
961
961
962
=item *
962
963
963
- The L<Test::Class::Moose::Config> class's C<args > method is now
964
- deprecated. This was a holdover from when Test::Class::Moose was both a parent
965
- class for your test classes and the test class runner.
964
+ The L<Test::Class::Moose::Config> class's C<args > method is now deprecated.
965
+ This was a holdover from when Test::Class::Moose was both a parent class for
966
+ your test classes and the test class runner.
966
967
967
968
=back
968
969
@@ -1001,10 +1002,9 @@ method was never intended to be run unconditionally.
1001
1002
=item *
1002
1003
1003
1004
Parallel testing now parallelizes test classes rather than individual test
1004
- instances. This is only relevant if your test suite contains parameterized
1005
- test classes. This is slightly less efficient, but made the internal test
1006
- running code much simpler and made it possible to fix reporting for parallel
1007
- test runs.
1005
+ instances. This is only relevant if your test suite contains parameterized test
1006
+ classes. This is slightly less efficient, but made the internal test running
1007
+ code much simpler and made it possible to fix reporting for parallel test runs.
1008
1008
1009
1009
=item *
1010
1010
@@ -1022,13 +1022,13 @@ The L<Test::Class::Moose::Runner> C<builder> method has been removed.
1022
1022
1023
1023
=item * The L<Test::Class::Moose::Report> class's C<all_test_classes > method is un-deprecated
1024
1024
1025
- This method now returns a list of L<Test::Class::Moose::Report::Class>
1026
- objects. A class report contains one or more instance reports.
1025
+ This method now returns a list of L<Test::Class::Moose::Report::Class> objects.
1026
+ A class report contains one or more instance reports.
1027
1027
1028
1028
=item *
1029
1029
1030
- Removed the L<Test::Class::Moose::Report::Instance> 's error
1031
- attribute. Contrary to the documentation, this attribute was never populated.
1030
+ Removed the L<Test::Class::Moose::Report::Instance> 's error attribute. Contrary
1031
+ to the documentation, this attribute was never populated.
1032
1032
1033
1033
=item *
1034
1034
@@ -1043,8 +1043,8 @@ L<Test::Class::Moose::Report> and L<Test::Class::Moose::Report::Method>.
1043
1043
1044
1044
=item *
1045
1045
1046
- Removed the long-deprecated C<<
1047
- Test::Class::Moose::Report::Method->add_to_plan method >>.
1046
+ Removed the long-deprecated C<< Test::Class::Moose::Report::Method->add_to_plan
1047
+ method >>.
1048
1048
1049
1049
=back
1050
1050
@@ -1054,16 +1054,16 @@ Test::Class::Moose::Report::Method->add_to_plan method >>.
1054
1054
1055
1055
=item * Running tests with Test::Class::Moose is deprecated - use L<Test::Class::Moose::Runner>
1056
1056
1057
- As of version 0.55, running tests and being a test class have been
1058
- separated. Your test classes should continue to C<use Test::Class::Moose > , but
1059
- your test runner script should use L<Test::Class::Moose::Runner> :
1057
+ As of version 0.55, running tests and being a test class have been separated.
1058
+ Your test classes should continue to C<use Test::Class::Moose > , but your test
1059
+ runner script should use L<Test::Class::Moose::Runner> :
1060
1060
1061
1061
use Test::Class::Moose::Load 't/lib';
1062
1062
use Test::Class::Moose::Runner;
1063
1063
Test::Class::Moose::Runner->new->runtests;
1064
1064
1065
- Calling C<< Test::Class::Moose->new->runtests >> still works, but is
1066
- deprecated and will issue a warning.
1065
+ Calling C<< Test::Class::Moose->new->runtests >> still works, but is deprecated
1066
+ and will issue a warning.
1067
1067
1068
1068
=item * Parallel testing is totally different
1069
1069
@@ -1074,8 +1074,8 @@ running tests in parallel.
1074
1074
=item * The L<Test::Class::Moose::Report> C<all_test_classes > method is deprecated
1075
1075
1076
1076
This has been replaced with the C<all_test_instances > method. The
1077
- C<all_test_classes > method is still present for backwards compatibility, but
1078
- it simply calls C<all_test_instances > under the hood.
1077
+ C<all_test_classes > method is still present for backwards compatibility, but it
1078
+ simply calls C<all_test_instances > under the hood.
1079
1079
1080
1080
=item * The C<Test::Class::Moose::Report::Class > class is gone
1081
1081
@@ -1116,9 +1116,9 @@ forgot it:
1116
1116
...
1117
1117
}
1118
1118
1119
- That second argument is still passed, but it's deprecated. It's now
1120
- recommended that you call the C<< $test->test_report >> method to get that.
1121
- Instead of this:
1119
+ That second argument is still passed, but it's deprecated. It's now recommended
1120
+ that you call the C<< $test->test_report >> method to get that. Instead of
1121
+ this:
1122
1122
1123
1123
sub test_froblinator {
1124
1124
my ( $test, $report ) = @_;
@@ -1173,9 +1173,9 @@ L<https://metacpan.org/release/Test-Class-Moose/>
1173
1173
=item * L<Test::Routine>
1174
1174
1175
1175
I always pointed people to this when they would ask about L<Test::Class> +
1176
- L<Moose> , but I would always hear "that's not quite what I'm looking for".
1177
- I don't quite understand what the reasoning was, but I strongly encourage you
1178
- to take a look at L<Test::Routine> .
1176
+ L<Moose> , but I would always hear "that's not quite what I'm looking for". I
1177
+ don't quite understand what the reasoning was, but I strongly encourage you to
1178
+ take a look at L<Test::Routine> .
1179
1179
1180
1180
=item * L<Test::Roo>
1181
1181
0 commit comments