Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Brilliant, I never thought of that. It works:
# foo.t use strict; use warnings; use Test::More qw/no_plan/; use Test::Exception; require_ok(q{foo.pl}); Log::Log4perl->appender_thresholds_adjust(7); # disable logging # ------ negative tests for add() ------ throws_ok { add(); } qr/error/i, q{Expect error when no args}; ... Log::Log4perl->appender_thresholds_adjust(-7); # enable logging # ------ positive tests for add() ------ cmp_ok(add(2,2), q{==}, 4, q{Expect 2+2=4}); # Note: I want a warning here: cmp_ok(add(1000,1000), q{==}, 2000, q{Expect 1000+1000=2000}); __END__
This gives me the warning I wanted:
$ prove foo.t foo......1/? [WARN] 2008/04/02 11:26:41 main::add foo.pl:20 - possible + overflow foo......ok All tests successful. Files=1, Tests=8, 1 wallclock secs ( 0.01 usr 0.00 sys + 0.08 cusr + 0.01 csys = 0.10 CPU) Result: PASS
Thanks Thilosophy!
--
Andreas

In reply to Re^6: Strategy for conditional logging in tests by andreas1234567
in thread Strategy for conditional logging in tests by andreas1234567

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 pondering the Monastery: (7)
As of 2024-03-28 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found