Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Is there any real consensus in the Perl community with respect to how unit testing ought to be done?

"Ought to be done" conflates two separate ideas: The first is the approach one takes to unit testing (e.g., TDD with or without mock objects, test-specific subclasses, etc.). Since the choice of approach is best dictated by the thing you're trying to build, and we're all building different things (albeit with some common themes), consensus here on a single approach is unlikely.

The second idea is about the specific testing tool or framework. A lot of unit testing in the non-Perl world uses some variant of xUnit, though the use of the tool may be less interesting than the choice of whether to mock, subclass, or whatever.

Which module, were I to use it, would cause the least scoffing from those in the know when it comes to unit testing Perl code?

I think you'll find that the scaffolding depends more on what you're trying to test than it does on your choice of testing framework. Test::More is a decent starting point. At work we use a custom subclass of Test which we're reasonably happy with. (And we have >12,000 unit tests.)

The fact that there is no well accepted standard is quite discouraging. Said lack makes it very difficult to do integration testing across modules, unless you could at least get everyone to agree to a common harness.

You're apparently seeing a problem here that I'm not. What do you mean by "integration across modules", and how does that vision depend on having a single test harness?

Edited to add: The part I find disappointing is that unit testing still isn't widely used.

In reply to Re: Unit Testing in Perl by dws
in thread Unit Testing in Perl by skyknight

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2020-11-26 07:52 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found