dougm       01/06/25 20:26:48

  Modified:    Apache-Test/lib/Apache Test.pm
  Log:
  beef up the Apache::Test docs a bit
  
  Revision  Changes    Path
  1.9       +57 -11    modperl-2.0/Apache-Test/lib/Apache/Test.pm
  
  Index: Test.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/Test.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Test.pm   2001/06/22 16:13:53     1.8
  +++ Test.pm   2001/06/26 03:26:47     1.9
  @@ -86,26 +86,72 @@
   
   =head1 NAME
   
  -Apache::Test -- Run tests with mod_perl-enabled Apache server
  +Apache::Test - Test.pm with helpers for testing Apache
   
   =head1 SYNOPSIS
   
       use Apache::Test;
   
  -    # plan 3 tests
  -    plan tests => 3, \&condition;
  +=head1 DESCRIPTION
   
  +B<Apache::Test> is a wrapper around the standard I<Test.pm> with
  +helpers for testing an Apache server.
  +
  +=head1 FUNCTIONS
  +
  +=over 4
  +
  +=item plan
  +
  +This function is a wrapper around I<Test::plan>.  If the first
  +argument is an object, such as an I<Apache::RequestRec> object,
  +C<STDOUT> will be tied to it.  If the last argument is a B<CODE>
  +reference, the tests will be skipped if the function returns false.
  +The I<Test.pm> global state will also be refreshed by calling
  +I<Apache::Test::test_pm_refresh>.  All other arguments are passed through
  +to I<Test::plan>. Examples:
  +
  +    # just like using Test.pm, plan 3 tests
  +    plan tests => 3;
  +
       # if condition() returns false, all the tests are skipped. 
       # e.g.: skip all tests if LWP is not available
       plan tests => 5, \&have_lwp;
   
  -    # ok() and skip() are imported from Test.pm (see Test.pm manpage)
  -    ok 'mod_perl rules'; # test 1 is passed (the string is true)
  -    ok 42;               # test 2 is passed (42 is always true)
  -    skip "why 42?"       # test 3 is skipped (print the reason: "why 42?")
  -    my @a = qw(a b);
  -    ok $a[0] eq $a[1];   # test 4 is failed ('a' ne 'b')
  -    ok ++$a[0] eq $a[1]; # test 5 is passed ('b' eq 'b')
  +    # first tie STDOUT to the request
  +    plan $r, tests => 7;
   
  -=cut
  +=item ok
  +
  +Same as I<Test::ok>, see I<Test.pm> documentation.
  +
  +=item skip
  +
  +Same as I<Test::skip>, see I<Test.pm> documentation.
  +
  +=item test_pm_refresh
   
  +Normally called by I<Apache::Test::plan>, this function will refresh
  +the global state maintained by I<Test.pm>, allowing C<plan> and
  +friends to be called more than once per-process.  This function is not
  +exported.
  +
  +=back
  +
  +=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;
  +
  +=cut
  
  
  

Reply via email to