Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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.


Comment on Re^6: Does anybody write tests first?
Select or Download Code
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/Existant.pm 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 Existant.pm 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://669628]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-08-22 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (145 votes), past polls