man Apache::TestMB () - Subclass of Module::Build to support Apache::Test

NAME

Apache::TestMB - Subclass of Module::Build to support Apache::Test

SYNOPSIS

Standard process for building & installing modules:

  perl Build.PL
  ./Build
  ./Build test
  ./Build install

Or, if you're on a platform (like DOS or Windows) that doesn't like the ./ notation, you can do this:

  perl Build.PL
  perl Build
  perl Build test
  perl Build install

DESCRIPTION

This class subclasses CWModule::Build to add support for testing Apache integration with Apache::Test. It is broadly based on CWApache::TestMM, and as such adds a number of build actions to a the Build script, while simplifying the process of creating Build.PL scripts.

Here's how to use CWApache::TestMB in a Build.PL script:

  use Module::Build;

  my $build_pkg = eval { require Apache::TestMB }
      ? 'Apache::TestMB' : 'Module::Build';

  my $build = $build_pkg->new(
      module_name => 'My::Module',
  );
  $build->create_build_script;

This is identical to how CWModule::Build is used. Not all target systems may have CWApache::Test (and therefore CWApache::TestMB installed, so we test for it to be installed, first. But otherwise, its use can be exactly the same. Consult the Module::Build documentation for more information on how to use it; Module::Build::Cookbook may be especially useful for those looking to migrate from CWExtUtils::MakeMaker.

INTERFACE

Build

With the above script, users can build your module in the usual CWModule::Build way:

  perl Build.PL
  ./Build
  ./Build test
  ./Build install

If CWApache::TestMB is installed, then Apache will be started before tests are run by the CWtest action, and shut down when the tests complete. Note that CWBuild.PL can be called CWApache::Test-specific options in addition to the usual CWModule::Build options. For example:

  perl Build.PL -apxs=/usr/local/apache/bin/apxs

Consult the Apache::Test documentation for a complete list of options.

In addition to the actions provided by CWModule::Build (CWbuild, CWclean, CWcode, CWtest, etc.), CWApache::TestMB adds a few extra actions:

test_clean
This action cleans out the files generated by the test script, t/TEST. It is also executed by the CWclean action.
run_tests
This action actually the tests by executing the test script, t/TEST. It is executed by the CWtest action, so most of the time it won't be executed directly.
testcover
CWApache::TestMB overrides this action from CWModule::Build in order to prevent the CWApache::Test preference files from being included in the test coverage.

Constructor

new

The CWnew() constructor takes all the same arguments as its parent in CWModule::Build, but can optionally accept one other parameter:

apache_test_script
The name of the CWApache::Test test script. The default value is t/TEST, which will work in the vast majority of cases. If you wish to specify your own file name, do so with a relative file name using Unix-style paths; the file name will automatically be converted for the local platform.

When CWnew() is called it does the following:

•
Processes the CWApache::Test-specific options in CW@ARGV. See the Apache::Test documentation for a complete list of options.
•
Sets the name of the CWApache::Test test script to t/TEST, unless it was explicitly specified by the CWapache_test_script parameter.
•
Calls CWgenerate_script() to generate CWApache::Test test script, usually t/TEST.

Instance Methods

apache_test_args

Returns a hash reference containing all of the settings specified by options passed to Build.PL, or explicitly added to CW@ARGV in Build.PL. Consult the Apache::Test documentation for a complete list of options.

apache_test_script

Gets or sets the file name of the CWApache::Test test script.

generate_script

  $build->generate_script;
  $build->generate_script('t/FOO');
  $build->generate_script(undef, 'Apache::TestRun');

This method is called by CWnew(), so in most cases it can be ignored. If you'd like it to use other than the default arguments, you can call it explicitly in Build.PL and pass it the arguments you desire. It takes two optional arguments:

•
The name of the CWApache::Test test script. Defaults to the value returned by CWapache_test_script().
•
The name of an CWApache::Test test running class. Defaults to CWApache::TestRunPerl.

If there is an existing t/TEST.PL (or a script with the same name as specified by the CWapache_test_script parameter but with .PL appended to it), then that script will be used as the template for the test script. Otherwise, a simple test script will be written similar to what would be written by CWApache::TestRun::generate_script() (although that function is not aware of the arguments passed to Build.PL, so use this one instead!).

SEE ALSO

Apache::TestRequest
Demonstrates how to write tests to send requests to the Apache server run by CW./Build test.
Module::Build
The parent class for CWApache::TestMB; consult it's documentation for more on its interface.
<http://www.perl.com/pub/a/2003/05/22/testing.html>
This article by Geoffrey Young explains how to configure Apache and write tests for your module using Apache::Test. Just use CWApache::TestMB instead of CWApache::TestMM to update it for use with CWModule::Build.

AUTHOR

David Wheeler

Questions can be asked at the test-dev <at> httpd.apache.org list. For more information see: http://httpd.apache.org/test/ and http://perl.apache.org/docs/general/testing/testing.html.