Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Application Testing: Custom Module or Perl Test Files?

by xdg (Monsignor)
on Sep 07, 2005 at 20:51 UTC ( [id://489996]=note: print w/replies, xml ) Need Help??


in reply to Application Testing: Custom Module or Perl Test Files?

It's also fairly common to have a hybrid between scripts and modules. You can create .t files for individual sets of tests, but place common functionality into a .pm file within the t/ directory that each of your .t files uses. As an extensive example of how this might work, see Test::Class -- though it's perfectly fine to just create a simple module with some helper functions, too, so you don't repeat them in your test scripts.

Personally, I think using Module::Starter to create your test module is overkill, as most of Module::Starter is oriented to creating a framework for packaging up modules for distribution which you don't really need.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

  • Comment on Re: Application Testing: Custom Module or Perl Test Files?

Replies are listed 'Best First'.
Re^2: Application Testing: Custom Module or Perl Test Files?
by geektron (Curate) on Sep 07, 2005 at 23:50 UTC
    Personally, I think using Module::Starter to create your test module is overkill, as most of Module::Starter is oriented to creating a framework for packaging up modules for distribution which you don't really need.

    I've been using ExtUtils::ModuleMaker instead of Module::Starter, though both focus on getting a developer started.

    i'd disagree about them being overkill, though, because they do create the basic organizational structure (directories, stub test files, etc) to get one in the habit of testing.

    additionally, at least ExtUtils::ModuleMaker has options to create multiple modules, which is *very* convenient.

      The more general point I was making was that when making a module to help with testing some other module or application, creating it with a whole distribution skeleton (README, MANIFEST, Changes, etc.) is unnecessary, whether using Module::Starter, Extutils::ModuleMaker or h2xs or something else entirely. It's sufficient to just create a .pm file and stick it in t/ directory.

      (N.B I'm the author of ExtUtils::ModuleMaker::TT, so, yes, I'm a fan of the ExtUtils::ModuleMaker school. And kudos to jkeenan1 for his recent updates!)

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        (N.B I'm the author of ExtUtils::ModuleMaker::TT, so, yes, I'm a fan of the ExtUtils::ModuleMaker school. And kudos to jkeenan1 for his recent updates!)

        heheheh.

        i've jumped on the testing team for ExtUtils::ModuleMaker, because i'd like to participate more, plus there are a few enhancements i'd like to see.

        the only reason i made my comment was that even if it can be considered "overkill" to use ExtUtils::ModuleMaker just to start testing, having that skeleton there helps one *remember* what's needed.

      I couldn't find where in the ExtUtils::ModuleMaker docs it mentions creating multiple modules, but in Module::Starter it shows it:

      module-starter --module=Foo::Bar,Foo::Bat \ --author="Andy Lester" --email=andy@petdance.com

      Maybe I completely missed it?

      Oh, and I like the look of Module::Starter::PBP:

      Module::Starter::PBP - Create a module as recommended in "Perl Best Practices"

      Walking the road to enlightenment... I found a penguin and a camel on the way.....
      Fancy a yourname@perl.me.uk? Just ask!!!
        well, here's a slightly edited script i used to start creating a bundle of modules for a project i'm trying to finish:
        #!/usr/bin/perl use ExtUtils::ModuleMaker; my $mod = ExtUtils::ModuleMaker->new( NAME => 'ConferenceBuilder', EXTRA_MODULES => [ { NAME => 'ConferenceBuilder::Foundation' }, { NAME => 'ConferenceBuilder::Instance' }, { NAME => 'ConferenceBuilder::Accreditations' }, { NAME => 'ConferenceBuilder::Products' }, { NAME => 'ConferenceBuilder::Sessions' }, { NAME => 'ConferenceBuilder::Addons' }, ], AUTHOR => { NAME =>'geektron', EMAIL => 'me@email.com', ORGANIZATION => 'Dis.Organized', WEBSITE => 'http://www +.perlmonks.org' }, VERSION => '0.01', LICENSE => 'artistic', ); $mod->complete_build();
        just chmod it to executable, and run.

        it made all the modules in the ConferenceBuilder tree and ConferenceBuilder.pm

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://489996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-20 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found