note
xdg
<p>That's a great point. I use that pattern also for when I may want to skip a test file entirely if a test dependency isn't available.
</p>
<code>
use Test::More;
eval { require Some::Crazy::Dependency };
if ($@) {
plan skip_all => "Some::Crazy::Dependency not available";
}
else {
plan tests => 42;
}
</code>
<p>It could be done in a <c>BEGIN</c> block, too, but I find it more readable without them.</p>
<div class="pmsig"><div class="pmsig-268515">
<p>-xdg</p>
<p><small><i>Code written by xdg and posted on PerlMonks is [http://creativecommons.org/licenses/publicdomain|public domain]. It is provided <b>as is</b> with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.</i></small></p>
</div></div>
524120
524144