Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I've been building an ecosystem of scripts for a client over the last few months, and recently I needed to make use of some functionality I'd left in place in one of my modules. Before starting development, I checked to see how the module tests were laid out, in order to give me more insight into how the module works, since I wrote it a few months ago.

Then I discovered there were no tests.

Narrator: A vague sense of unease flitted through the developer's mind, but he resolutely shrugged it off.

OK, no problem -- I'd just write the tests, as it was a fairly simple module.

Narrator: But it wasn't as simple as he imagined it to be.

After writing the tests, I came to the realization that the way I'd written the module meant it wasn't as extensible as I originally thought. And tests might have revealed that shortcoming.

So I spent some development time more clearly defining what I wanted to module to do, how it should be called, and made changes in one of the scripts that use the module. And found some more issues.

Narrator: Several cups of coffee later ..

The good news is that I now have a module that works the way I need it to, complete with tests that show that it works correctly. All of the scripts that use this module have been updated. And tomorrow I can start work on the feature that uses this improvement.

But the moral of the story remains: It doesn't matter how simple a module is. As soon as you decided you'd put some logic into a module -- that's the point that you should have also written the tests that prove that the module's logic is correct. There's not no excuse for skipping that part.

You've gotta have tests!

Update: Minor edit: not -> no in second to last paragraph.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.


In reply to You've gotta have tests! by talexb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-22 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found