The short answer? When no more bugs are found and you've stopped writing code, or when the code stops being used.

I find there are two modes for writing tests: proactive and reactive. In reactive testing you write a test when a bug is found (and before it is fixed) that fires for the buggy code and succeeds when the bug has been fixed.

Proactive testing checks against coding issues, edge cases in the data and unusual interactions with the user interface. The data tests are generated by code inspection and knowledge of the problem domain. The interaction tests are generated by inspecting the UI and by doing "silly stuff" (idiot proofing tests).

Proactive tests tend to be written as the code is written (before if you are writing test driven code) and reactive tests are obviously written after the code. Reactive tests may often be written to further test issues found by proactive tests.

Writing proactive tests tends to finish when you have finished writing the code. Reactive test writing finishes when bugs stop being detected.


DWIM is Perl's answer to Gödel

In reply to Re: when do you stop writing test? by GrandFather
in thread when do you stop writing test? by Qiang

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!
  • 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, details, 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, summary, 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.