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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:20:18+00:00 2026-06-13T04:20:18+00:00

I write some test cases for a function foo . Some test cases fail,

  • 0

I write some test cases for a function foo.

Some test cases fail, and to debug and find the problem, I wish to print some debug messages inside function foo.

My attempts are:

  • Print to stdout, later I learned that Test::More does not want me to modify stdout.
  • Print to stderr, my messages are not shown when I execute make test

I learned about diag note and explain, I did diag('test') inside foo however the message is not printed. Examples of them show that they are to be used inside test case function.

I really want to print a message in my foo when I run test case for it!

So what is the most correct way to achieve this?

  • 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-06-13T04:20:19+00:00Added an answer on June 13, 2026 at 4:20 am

    Thanks for everyone’s attention.

    I figured this out finally..

    In my function

    sub foo {
        diag('hahahah');
    }
    

    In my test:

    ok(Package::foo());
    

    And I did not see ‘hahahaha’ output when I ran perl Makefile.PL; make test

    I read perldoc of Test::More and noticed that the example usages of diag/note are from the test file, not from the tested function,and that confused me little bit: I thought diag/note could ONLY be used in test case, not in the tested function.

    Then why did not ‘hahahah’ print out at first place?

    The reason is that… I did not use Test::More; in the package of foo. After put the line in there, I could see ‘hahahah’ in output.

    I did not receive warning about diag not found.

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

Sidebar

Related Questions

I want to write some test cases for my web app, but stuck at
I am trying to write some test cases (first time) using jasmine describe(Widget App
I'm a student, and I'm trying to write and run some test code for
I am using py.test to write some tests and in my tests I utilize
I want to write some integration-tests for my connect-middleware and test it with real-http-requests
i just join phonegap, i want a built test application. i write some code
Is it possible to write and run with Visual Studio 2008 some unit test
I used Response.Write to write dynamic javascript into a page to test some values
I recently had this question in an interview to write test cases to test
I'm using Selenium RC to write test cases for a website that's at least

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.