in reply to Re^5: Developing a module, how do you do it ?
in thread Developing a module, how do you do it ?
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.
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Developing a module, how do you do it ?
by BrowserUk (Patriarch) on Mar 04, 2012 at 03:14 UTC | |
by tobyink (Canon) on Mar 04, 2012 at 07:53 UTC | |
by BrowserUk (Patriarch) on Mar 04, 2012 at 09:51 UTC | |
by tobyink (Canon) on Mar 05, 2012 at 11:24 UTC | |
by BrowserUk (Patriarch) on Mar 05, 2012 at 11:46 UTC | |
by chromatic (Archbishop) on Mar 04, 2012 at 05:48 UTC | |
by BrowserUk (Patriarch) on Mar 04, 2012 at 05:57 UTC | |
by chromatic (Archbishop) on Mar 04, 2012 at 06:57 UTC | |
by BrowserUk (Patriarch) on Mar 04, 2012 at 07:17 UTC |