Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Yes, like xdg I try to write the tests first and I find it very rewarding. Not only does it force me to think more thoroughly, in the process of making the code testable, it also makes (IMHO) the logic stand out more clearly.

I acknowledge that BrowserUK has a point on the numbers, dots and percentages scroll, but I disagree in that this should prevent one from writing tests first. I usually write one (or more) test file(s) per sub, which again makes it fairly simple to narrow down on specific code, and using diag and the more verbose functions of Test::More et al. should render it obvious what went wrong in the event of failure.

As for pitfalls, I think of easy of change. Having both a test suite and code (as opposed to just code) means there is more to change. For smaller scripts where you feel very confident, having to rewrite the tests and the code can be burdensome. Then again, that may be a good thing as it forces you to think while letting you change one section at the time and making sure that it all still works as intended. In overall I don't this this should prevent you from writing (at least some or most of the) tests first.


In reply to Re: Does anybody write tests first? by andreas1234567
in thread Does anybody write tests first? by amarquis

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (3)
    As of 2020-10-30 02:34 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (277 votes). Check out past polls.