Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:05:33+00:00 2026-05-29T07:05:33+00:00

The docs I find around the ’net and the book I have, Perl Testing

  • 0

The docs I find around the ’net and the book I have, Perl Testing, either say or suggest that unit-testing for Perl is usually done when creating modules.

Is this true? Is there no way to unit-test actual programs using Test::More and cousins?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:05:34+00:00Added an answer on May 29, 2026 at 7:05 am

    Of course you can test scripts using Test::More. It’s just harder, because most scripts would need to be run as a separate process from which you capture the output, and then test it against expected output.

    This is why modulinos (see chapter 17 in: brian d foy, Mastering Perl, second edition, O’Reilly, 2014) were developed. A modulino is a script that can also be used as a module. This makes it easier to test, as you can load the modulino into your test script and then test its functions like you would a regular module.

    The key feature of a modulino is this:

    #! /usr/bin/perl
    package App::MyName; # put it in a package
    
    run() unless caller; # Run program unless loaded as a module
    
    sub run {
      ... # your program here
    }
    

    The function doesn’t have to be called run; you could use main if you’re a C programmer. You’d also normally have additional subroutines that run calls as needed.

    Then your test scripts can use require "path/to/script" to load your modulino and exercise its functions. Since many scripts involve writing output, and it’s often easier to print as you go instead of doing print sub_that_returns_big_string(), you may find Test::Output useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been digging around the docs but cannot find if there is a function
I've googled around and searched the MYSQL docs ad nauseam and couldn't find a
The Adobe docs (I can't find which) state that Flash can read Shared Objects
I can't find anything anywhere(search engines, docs, here, etc) that shows how to create
In the MVC RC 2 docs , we find: Expression-based helpers that render input
I've dug around a bit in the Eventkit/EventkitUI docs and couldn't find an answer.
I've looked over the Lua & LuaFileSystem Docs and have yet to find a
I find Oleg's docs on Iteratee somewhat difficult to get into. Especially since some
The docs for Dictionary.TryGetValue say: When this method returns, [the value argument] contains the
The docs for Uri.LocalPath don't say what happens if you feed it a non

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.