And some of those .t file are huge and have hundreds of tests.

So the tests are "huge" yet you want to put them at the end of the module, and force perl to parse them each time the module is loaded?

It will tell you test number 271 failed. If you are lucky -- and you need to jump though more hoops to make it happen -- it might tell your in what .t file and where the failing test happened.

The Test::More/Test::Simple family of modules report a lot more than that on a test failure. At a minimum they report the test number, line number and filename where the test occurred.

The documentation for these testing modules strongly encourages you (see footnotes in "readmore" section below) to give each test a name. e.g.:

is($obj->name, "Bob", "object has correct name");

If that test fails, you get a report along the lines of:

ok 1 - object can be instantiated
not ok 2 - object has correct name
#   Failed test 'object has correct name'
#   at t/mytests.t line 12.
#          got: 'Alice'
#     expected: 'Bob'
ok 3 - object can be destroyed

This makes it pretty easy to see which test has failed, and why it's failed.


footnotes

From Test::Simple:

If you provide a $name, that will be printed along with the "ok/not ok" to make it easier to find your test when if fails (just search for the name). It also makes it easier for the next guy to understand what your test is for. It's highly recommended you use test names.

From Test::More:

All test functions take a name argument. It's optional, but highly suggested that you use it.


In reply to Re^6: Developing a module, how do you do it ? by tobyink
in thread Developing a module, how do you do it ? by mascip

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.