Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

If you've distributed a module for others to use, you might find that you want to use Test::Differences in your tests, but users might not want yet another module to install. You might want the verbose output of Test::Differences because it makes tracking down problems much easier, but hey, getting a less verbose test report is better than none at all (hell, consider yourself lucky if you get any test reports).

I want to upgrade Class::Trait soon and make the use of Test::Differences optional with code similar to the following:

#!/usr/bin/perl use strict; use warnings; use Test::More tests => 2; BEGIN { eval "use Test::Differences"; if ($@) { *eq_or_diff = \&is_deeply; } } eq_or_diff [ 3, 2 ], [ 3, 2 ], 'first test'; eq_or_diff [ 3, 2 ], [ 3, 2, 1 ], 'second test';

If they have Test::Differences, great. If they don't, they fall back to the Test::More::is_deeply behavior. Not as useful for diagnostics, but better than nothing.

This is something I'm thinking about more and more because while I don't see why users should object to another test module being installed, the reality is, the fewer dependencies we require, the more likely our modules are to be used. I might even use a trick like making a custom test module to make this easier to manage (such as having an optional Test::NoWarnings) and other things.

I recommend all programmers looking at distributing code for general use figure out ways that can gracefully downgrade functionality (if appropriate) rather than force people to install stuff which they may not want or which might itself be difficult to install. POD tests, for example, are excellent candidates for skipping entirely on an end user's machine.

Cheers,
Ovid

New address of my CGI Course.


In reply to Gracefully Downgrading Behavior by Ovid

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found