Refactorings can easily result in green-bar code that wasn't immediately motivated by failing tests and that contains untested branches.

Fair point. Misunderstood what you were getting at.

That said, it's still been my experience that doing TDD and merciless refactoring produces good branch coverage more easily that post-code test writing. My hunch would be that refactorings that introduce untested branches are more than outweighed by those that remove branches or cause duplicate coverage by different test. Just a hunch tho'.

Seems we aren't really in much disagreement after all.

No, I don't think so ;-)

My original point was only that too often I've seen TDD adopted "at the expense" of more traditional testing methods rather than as a complementary "design" process.

Bad things can and do happen if people jump into a new development style and abandon an old one. The problem I see most with people adopting TDD is, well, not doing TDD :-). It's so very easy for a newbie to write code that "obviously" works, or fail to write tests for something that is hard to test rather than re-writing the code to make it easier to test.

Traditional testing methods like looking at code and branch coverage can actually be great tools for supporting TDD. Its been my experience that if you've got low code coverage then you almost certainly are not doing TDD properly, so it's great feedback into the process of adopting and maintaining good TDD practices.

Of course with infinite time and money you do every kind of testing practice that you think will benefit you. Unfortunately that's not a common scenario. My personal experience is that if you have a team doing TDD well then it's better to spend your testing resources in the acceptance/customer tests and in exploratory testing rather than more formal whitebox techniques. As ever YMMV ;-)


In reply to Re^7: Automatic generation of tests by adrianh
in thread Automatic generation of tests by DrHyde

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.