G'day Bod,

Excellent analysis by ++hv. Here's some additional tips.

Here's a simple test script (pm_11152486_test_more.t):

#!perl use strict; use warnings; use Test::More tests => 3; my ($var1, $var2) = (1, 2); # Test1 ok($var1 == $var2, 'Fail: ok()'); # Test2 is($var1, $var2, 'Fail: is()'); # Test3 ok($var2 == $var1, 'Fail: ok()') or diag "\$var1[$var1] \$var2[$var2]";

In simple cases, you can interpolate the values of the arguments into the test name; e.g.

ok($var1 == $var2, "Fail: ok($var1 == $var2)");

in which case, diag() is unnecessary.

In more complex cases, doing this is not easy, or can result in cumbersome test names; or you may want additional information such as values from %ENV. This is where diag() can be particularly useful.

Here's a straightforward run of that code:

$ perl pm_11152486_test_more.t 1..3 not ok 1 - Fail: ok() # Failed test 'Fail: ok()' # at pm_11152486_test_more.t line 11. not ok 2 - Fail: is() # Failed test 'Fail: is()' # at pm_11152486_test_more.t line 14. # got: '1' # expected: '2' not ok 3 - Fail: ok() # Failed test 'Fail: ok()' # at pm_11152486_test_more.t line 17. # $var1[1] $var2[2] # Looks like you failed 3 tests of 3.

Consider the prove utility for additional output information:

$ prove pm_11152486_test_more.t pm_11152486_test_more.t .. 1/3 # Failed test 'Fail: ok()' # at pm_11152486_test_more.t line 11. # Failed test 'Fail: is()' # at pm_11152486_test_more.t line 14. # got: '1' # expected: '2' # Failed test 'Fail: ok()' # at pm_11152486_test_more.t line 17. # $var1[1] $var2[2] # Looks like you failed 3 tests of 3. pm_11152486_test_more.t .. Dubious, test returned 3 (wstat 768, 0x300) Failed 3/3 subtests Test Summary Report ------------------- pm_11152486_test_more.t (Wstat: 768 (exited 3) Tests: 3 Failed: 3) Failed tests: 1-3 Non-zero exit status: 3 Files=1, Tests=3, 0 wallclock secs ( 0.05 usr 0.02 sys + 0.03 cusr + 0.09 csys = 0.19 CPU) Result: FAIL

Use the -v option for verbose output:

$ prove -v pm_11152486_test_more.t pm_11152486_test_more.t .. 1..3 not ok 1 - Fail: ok() not ok 2 - Fail: is() not ok 3 - Fail: ok() # Failed test 'Fail: ok()' # at pm_11152486_test_more.t line 11. # Failed test 'Fail: is()' # at pm_11152486_test_more.t line 14. # got: '1' # expected: '2' # Failed test 'Fail: ok()' # at pm_11152486_test_more.t line 17. # $var1[1] $var2[2] # Looks like you failed 3 tests of 3. Dubious, test returned 3 (wstat 768, 0x300) Failed 3/3 subtests Test Summary Report ------------------- pm_11152486_test_more.t (Wstat: 768 (exited 3) Tests: 3 Failed: 3) Failed tests: 1-3 Non-zero exit status: 3 Files=1, Tests=3, 0 wallclock secs ( 0.00 usr 0.09 sys + 0.03 cusr + 0.08 csys = 0.20 CPU) Result: FAIL

In situations where make test (or other variants of make) has shown some test scripts to have failed; rerun the failed tests individually with as much output as possible. From the same directory that you ran make test, run

prove -vb t/failed_test.t

In your example, 00-load.t was OK but 01-openai.t was not. So run:

prove -vb t/01-openai.t

You can run prove with multiple files; I generally don't — normally the output from one file is enough to deal with at once. :-)

— Ken


In reply to Re: Test::More fails... by kcott
in thread Test::More fails... by Bod

Title:
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, details, 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, summary, 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.