Apache-Test
view release on metacpan or search on metacpan
lib/Apache/Test.pm view on Meta::CPAN
If no arguments are passed, the reference to the variables hash is
returned. If one or more arguments are passed the corresponding values
are returned.
=back
=head1 Test::More Integration
There are a few caveats if you want to use I<Apache::Test> with
I<Test::More> instead of the default I<Test> backend. The first is
that I<Test::More> requires you to use its own C<plan()> function
and not the one that ships with I<Apache::Test>. I<Test::More> also
defines C<ok()> and C<skip()> functions that are different, and
simply C<use>ing both modules in your test script will lead to redefined
warnings for these subroutines.
To assist I<Test::More> users we have created a special I<Apache::Test>
import tag, C<:withtestmore>, which will export all of the standard
I<Apache::Test> symbols into your namespace except the ones that collide
with I<Test::More>.
use Apache::Test qw(:withtestmore);
use Test::More;
plan tests => 1; # Test::More::plan()
ok ('yes', 'testing ok'); # Test::More::ok()
Now, while this works fine for standard client-side tests
(such as C<t/basic.t>), the more advanced features of I<Apache::Test>
require using I<Test::More> as the sole driver behind the scenes.
Should you choose to use I<Test::More> as the backend for
server-based tests (such as C<t/response/TestMe/basic.pm>) you will
need to use the C<-withtestmore> action tag:
use Apache::Test qw(-withtestmore);
sub handler {
my $r = shift;
plan $r, tests => 1; # Test::More::plan() with
# Apache::Test features
ok ('yes', 'testing ok'); # Test::More::ok()
}
C<-withtestmore> tells I<Apache::Test> to use I<Test::More>
instead of I<Test.pm> behind the scenes. Note that you are not
required to C<use Test::More> yourself with the C<-withtestmore>
option and that the C<use Test::More tests =E<gt> 1> syntax
may have unexpected results.
Note that I<Test::More> version 0.49, available within the
I<Test::Simple> 0.49 distribution on CPAN, or greater is required
to use this feature.
Because I<Apache:Test> was initially developed using I<Test> as
the framework driver, complete I<Test::More> integration is
considered experimental at this time - it is supported as best as
possible but is not guaranteed to be as stable as the default I<Test>
interface at this time.
=head1 Apache::TestToString Class
The I<Apache::TestToString> class is used to capture I<Test.pm> output
into a string. Example:
Apache::TestToString->start;
plan tests => 4;
ok $data eq 'foo';
...
# $tests will contain the Test.pm output: 1..4\nok 1\n...
my $tests = Apache::TestToString->finish;
=head1 SEE ALSO
The Apache-Test tutorial:
L<http://perl.apache.org/docs/general/testing/testing.html>.
L<Apache::TestRequest|Apache::TestRequest> subclasses LWP::UserAgent and
exports a number of useful functions for sending request to the Apache test
server. You can then test the results of those requests.
Use L<Apache::TestMM|Apache::TestMM> in your F<Makefile.PL> to set up your
distribution for testing.
=head1 AUTHOR
Doug MacEachern with contributions from Geoffrey Young, Philippe
M. Chiasson, Stas Bekman and others.
Questions can be asked at the test-dev <at> httpd.apache.org list
For more information see: http://httpd.apache.org/test/.
=cut
( run in 0.803 second using v1.01-cache-2.11-cpan-e1769b4cff6 )