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


Standard process for building & installing modules:

  perl Build.PL
  ./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


This class subclasses "Module::Build" to add support for testing Apache integration with Apache::Test. It is broadly based on "Apache::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 "Apache::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',

This is identical to how "Module::Build" is used. Not all target systems may have "Apache::Test" (and therefore "Apache::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 "ExtUtils::MakeMaker".


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

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

If "Apache::TestMB" is installed, then Apache will be started before tests are run by the "test" action, and shut down when the tests complete. Note that "Build.PL" can be called "Apache::Test"−specific options in addition to the usual "Module::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 "Module::Build" ("build", "clean", "code", "test", etc.), "Apache::TestMB" adds a few extra actions:

This action cleans out the files generated by the test script, t/TEST. It is also executed by the "clean" action.


This action actually the tests by executing the test script, t/TEST. It is executed by the "test" action, so most of the time it won’t be executed directly.


"Apache::TestMB" overrides this action from "Module::Build" in order to prevent the "Apache::Test" preference files from being included in the test coverage.


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

The name of the "Apache::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 "new()" is called it does the following:

Processes the "Apache::Test"−specific options in @ARGV. See the Apache::Test documentation for a complete list of options.

Sets the name of the "Apache::Test" test script to t/TEST, unless it was explicitly specified by the "apache_test_script" parameter.

Calls "generate_script()" to generate "Apache::Test" test script, usually t/TEST.

Instance Methods

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


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


  $build−>generate_script(undef, 'Apache::TestRun');

This method is called by "new()", 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 "Apache::Test" test script. Defaults to the value returned by "apache_test_script()".

The name of an "Apache::Test" test running class. Defaults to "Apache::TestRunPerl".

If there is an existing t/TEST.PL (or a script with the same name as specified by the "apache_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 "Apache::TestRun::generate_script()" (although that function is not aware of the arguments passed to Build.PL, so use this one instead!).



Demonstrates how to write tests to send requests to the Apache server run by "./Build test".


The parent class for "Apache::TestMB"; consult it’s documentation for more on its interface.


This article by Geoffrey Young explains how to configure Apache and write tests for your module using Apache::Test. Just use "Apache::TestMB" instead of "Apache::TestMM" to update it for use with "Module::Build".


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.


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.