Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

If you've not come across them already take a look at Test::Simple, Test::More and Test::Tutorial.

You might also find Test::Class of interest (but since I wrote that one I may be biased :-)

As to what you test - I tend to write all my code "Test First". Basically this means:

  1. I write the test for what I want my code to do.
    This (of course) fails since there isn't any code yet.
  2. I then write code until my test passes.
  3. Then, since I know I've finished and can move along to the next piece of functionality that needs testing.

Works very well for me. I get into the coding "flow" much faster this way and end up with very robust code.

Test suites also make changing your code a much less stressful business since you immediately know if you've broken anything.

I always have a window open that sits there doing a make test every time any file in my project changes. Instant feedback. Very handy.

This style comes from Extreme Programming (also known as XP - just be be confusing). If you're interested take a look at extremeprogramming.org.

Retrofitting a test suite on an existing code base can be a much more painful task. Two approaches that have worked for me are:

  1. Testing the documentation (Test::Tutorial has an example of this).
  2. Write tests for any bit of code that you need to change. That way you can check that you don't break anything as you make the change, and you will gradually build up a set of tests for the whole code base.

In reply to Re: What goes in a test suite? by adrianh
in thread What goes in a test suite? by Marza

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

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

      The best computer themed movie is:











      Results (172 votes), past polls