Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^6: Does anybody write tests first?

by kyle (Abbot)
on Feb 22, 2008 at 18:50 UTC ( #669628=note: print w/replies, xml ) Need Help??

in reply to Re^5: Does anybody write tests first?
in thread Does anybody write tests first?

unless you are testing more than one module from that test script (which I assume no one does)

Sorry this was unclear. When I wrote of a "simple sanity check before deployment", I actually did mean a test script that does nothing but use_ok over and over with no other tests.

When I've had a project with numerous modules, I have found it useful to have use_ok tests for all of them in one place.

my @modules = get_module_list(); plan 'tests' => scalar @modules; foreach my $module ( @modules ) { use_ok( $module ); }

If get_module_list() is bright enough to use File::Find, it will pick up modules without me having to explicitly list them. I get a sanity check on even those modules for which I haven't written more extensive tests. As I said, if your other testing isn't very good, checking that use works is a start.

Replies are listed 'Best First'.
Re^7: Does anybody write tests first?
by BrowserUk (Pope) on Feb 22, 2008 at 21:09 UTC

    For the reasons given in {net information loss), I see no advantage to your script over:

    my @modules = get_module_list(); foreach my $module ( @modules ) { require $module; }

    Except that you might discover more than one missing/corrupted module. But, and a very significant one IMO, is that you sould lose the information that told you why the (first) module failed to load. Eg.

    • Module missing:
      Can't locate Non/ in @INC (@INC contains: C:/Perl/lib C:/Pe +rl/site/lib .) at BEGIN failed--compilation aborted at -e line 1.
    • Compilation error:
      syntax error at line 2, near ") {" Compilation failed in require at -e line 1. BEGIN failed--compilation aborted at -e line 1.
    • Other(s)?

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://669628]
[stevieb]: I am thankful that I fell into Perl years ago in the manner I did. I don't believe there is another language that people care about so much, that they're willing to give everything. Langs come and go, but in Perl, it seems, things remain consistent.
[stevieb]: The people back then (~2000) are the same people now, but with much more experience. I'm appreciative that I fell into the Perl rabbit hole.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-02-25 01:22 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (364 votes). Check out past polls.