perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-docs/src/devel/writing_tests writing_tests.pod
Date Mon, 17 Sep 2001 15:30:02 GMT
stas        01/09/17 08:30:02

  Modified:    src/devel/writing_tests writing_tests.pod
  Log:
  Starting to document Apache::Test functionality
  
  Revision  Changes    Path
  1.4       +99 -0     modperl-docs/src/devel/writing_tests/writing_tests.pod
  
  Index: writing_tests.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/devel/writing_tests/writing_tests.pod,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- writing_tests.pod	2001/09/15 18:49:02	1.3
  +++ writing_tests.pod	2001/09/17 15:30:02	1.4
  @@ -607,6 +607,105 @@
   how amazingly it works and how amazingly it can be deployed by other
   users.
   
  +=head1 Gory Details on Writing Tests
  +
  +Here we cover in details some features useful in writing tests:
  +
  +=head2 Apache::Test functions
  +
  +B<Apache::Test> is a wrapper around the standard I<Test.pm> with
  +helpers for testing an Apache server.
  +
  +META: merge with Apache::Test's inlined scarce docs
  +
  +=over
  +
  +=item * ok()
  +
  +Same as I<Test::ok>, see I<Test.pm> documentation.
  +META: expand
  +
  +=item * skip()
  +
  +Same as I<Test::skip>, see I<Test.pm> documentation.
  +META: expand
  +
  +=item * sok()
  +
  +META: to be written
  +
  +=item * plan() and test_module()
  +
  +Whenever you start a new test, you have to declare how many sub-tests
  +it includes.  This is done easily with:
  +
  +  use Apache::Test;
  +  plan tests => 10; # run 10 tests
  +
  +Now if you want to skip the whole test use the third argument to plan():
  +
  +  plan tests => $ntests, \&condition;
  +
  +if condition() returns false, the whole test is skipped. For example
  +if some optional feature relying on 3rd party module is tested and it
  +cannot be found on user's system, you can say
  +
  +  plan tests => $ntests, test_module 'Chatbot::Eliza';
  +
  +here test_module() is used to test whether C<Chatbot::Eliza> is
  +installed.
  +
  +plan() is a wrapper around C<Test::plan>.  If the first argument is an
  +object, such as an C<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 as we have just seen. The I<Test.pm>
  +global state will also be refreshed by calling
  +C<Apache::Test::test_pm_refresh>.
  +
  +All other arguments are passed through to I<Test::plan>.
  +
  +=item * have_module()
  +
  +have_module() tests for existance of Perl modules or C modules
  +I<mod_*>. Accepts a list of modules or a reference to the
  +list. Returns FALSE if at least one of the modules is not found,
  +returns true otherwise.
  +
  +=item * test_module()
  +
  +A condition to Apache::Test::plan() must be passed as a last argument
  +and must be a reference. If it's not the arguments are passed to
  +C<Test::plan()> as is. Therefore if we want to test use have_module,
  +we either have to do:
  +
  +  plan tests => 1 + @test_strings, [have_module 'Chatbot::Eliza'];
  +
  +or to use test_module() that passes the reference for us:
  +
  +  plan tests => 1 + @test_strings, test_module 'Chatbot::Eliza';
  +
  +=item * have_lwp()
  +
  +META: to be written
  +
  +=item * have_http11()
  +
  +META: to be written
  +
  +=item * have_cgi()
  +
  +META: to be written
  +
  +=item * have_apache()
  +
  +META: to be written
  +
  +
  +=back
  +
  +
   =head1 When Tests Should Be Written
   
   =head2 New feature is Added
  
  
  

Mime
View raw message