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 7073597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:56:54+00:00 2026-05-28T05:56:54+00:00

I’m building a perl application as a modulino to make testing easier. The directory

  • 0

I’m building a perl application as a “modulino” to make testing easier. The directory structure looks something like this:

MainScript.pm
t/001_load.t
t/002_setup.t
t/003_etc...

The first test in each .t test file also loads the module with:

BEGIN { use_ok('MainScript'); }

For testing, I run the following in the top level directory:

prove -l

Everything up to this point works great. Where I run into a concern is when I accidentally run the .t test scripts directly.

My fingers have an almost autonomic habit of hitting the hotkey to run a script immediately after saving it in my text editor. When I do this with one of the test files, it dutifully runs and reports failure across the board. This is expected since it can’t see the module if run from its own directory. My concern is that some tests write to the file system. Examples being config files and data files used for verification. My preference would be for the test script to croak before it does anything if it can’t load the module it’s supposed to be testing. That way, I don’t have to worry about anything going haywire from the rest of the test.

The solution I’m currently working with is to replace the BEGIN { use_ok('MainScript'); } line with a standard use call:

use MainScript;

Running test with prove -l still works as expected. Even though the use_ok test was removed it’s obviously okay since the rest of the file runs. If, for some reason, the test can’t find the module, it chokes and “prove” still shows the test file as failing. If I run the script directly from the editor, it fails at compile time with a message that it can’t find the requested module in @INC. This seems like a desirable behavior to me.

Is there a better way to do this, and/or is there something in this approach that will bite me down the road?

  • 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-28T05:56:55+00:00Added an answer on May 28, 2026 at 5:56 am

    That’s the way I’ve always done it.

    I have one test (usually named 00-load.t) that does use_ok and nothing else (except print the version number). All the tests that actually exercise the module do a normal use, because if that fails, there’s no point in proceeding with the tests.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.