<p>Reading over the responses to this question <a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development">Disadvantages of Test Driven Development?</a> I got the impression there is alot of misunderstanding on what TDD is and how it should be conducted. It may prove useful to address these issues here.</p>

[{'answer_id': 72161, 'author': 'Ian P', 'author_id': 10853, 'author_profile': 'https://Stackoverflow.com/users/10853', 'pm_score': 0, 'selected': False, 'text': '<p>The misconception that I often see is that TDD ensures good results.</p>\n\n<p>Often times tests are written off of flawed requirements, and therefore, the developers produce a product that does not do what the user is expecting. Key to TDD is, in my opinion, working with the users to define requirements while helping manage their expectations.</p>\n'}, {'answer_id': 72230, 'author': 'Sklivvz', 'author_id': 7028, 'author_profile': 'https://Stackoverflow.com/users/7028', 'pm_score': 0, 'selected': False, 'text': "<p>These are the issues that in my opinion are quite controversial and hence prone to misunderstanding:</p>\n\n<ul>\n<li><p>In my experience the biggest advantage is producing far better code at the cost of a lot of time spent writing tests. So it's really worthwhile for projects that require high quality, but on some other, less quality centric sites, the extra time will not be worth the effort.</p></li>\n<li><p>People seem to think that only a major subset of the features must be tested, but that is actually wrong IMHO. You need to test everything in order for your test to be valid after refactoring.</p></li>\n<li><p>The big drawback of TDD is the false sense of security given by incomplete tests: I've seen sites go down because people assumed that Unit Testing was enough to trigger a deployment.</p></li>\n<li><p>There is no need of mocking frameworks to do TDD. It's just a tool for testing some cases in an easier way. The best unit tests though are fired high in the stack and should be agnostic on the layers in the code. Testing one layer at a time is meaningless in this context.</p></li>\n</ul>\n"}, {'answer_id': 72253, 'author': 'Mendelt', 'author_id': 3320, 'author_profile': 'https://Stackoverflow.com/users/3320', 'pm_score': 1, 'selected': False, 'text': "<p>I see a lot of people misunderstanding what tests actually are usefull to TDD. People write big acceptance tests instead of small unit tests and then spend far too much time maintaining their tests and then conclude that TDD doesn't work. I think the BDD people have a point in avoiding the use of the word test entirely.</p>\n\n<p>The other extreme is that people stop doing acceptance testing and think that because they do unit testing their code is tested. This is again a misunderstanding of the function of a unit test. You still need acceptance tests of some sort.</p>\n"}, {'answer_id': 72324, 'author': 'Chris Canal', 'author_id': 5802, 'author_profile': 'https://Stackoverflow.com/users/5802', 'pm_score': 5, 'selected': True, 'text': '<p>I feel the accepted answer was one of the weakest (<a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#67184">Disadvantages of Test Driven Development?</a>), and the most up-modded answer smells of someone who might be writing over specified tests.</p>\n\n<blockquote>\n  <p>Big time investment: for the simple\n  case you lose about 20% of the actual\n  implementation, but for complicated\n  cases you lose much more.</p>\n</blockquote>\n\n<p>TDD is an investment.  I\'ve found that once I was fully into TDD, the time I lost is very very little, and what time I did lose was more than made up when it came to maintence time.</p>\n\n<blockquote>\n  <p>For complex cases your test cases are\n  harder to calculate, I\'d suggest in\n  cases like that to try and use\n  automatic reference code that will run\n  in parallel in the debug version /\n  test run, instead of the unit test of\n  simplest cases.</p>\n</blockquote>\n\n<p>If your test are becoming very complex, it might be time to review your design.  TDD should lead you down the path smaller, less complex units of code working together</p>\n\n<blockquote>\n  <p>Sometimes you the design is not clear at the start and evolves as you go along - this will force you to redo your test which will generate a big time lose. I would suggest postponing unit tests in this case until you have some grasp of the design in mind.</p>\n</blockquote>\n\n<p>This is the worst point of them all!  TDD should really be "Test Driven <strong>Design</strong>".  TDD is about design, not testing.  To fully realise the value of benefits of TDD, you have toy <strong>drive</strong> your design from your tests.  So you should be <em>redoing</em> your production code to make your tests pass, not the other way round as this point suggests</p>\n\n<p>Now the currently most upmodded: <a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#64381">Disadvantages of Test Driven Development?</a></p>\n\n<blockquote>\n  <p>When you get to the point where you have a large number of tests, changing the system might require re-writing some or all of your tests, depending on which ones got invalidated by the changes. This could turn a relatively quick modification into a very time-consuming one.</p>\n</blockquote>\n\n<p>Like the accepted answers first point, this seems like over specification in the tests and a general lack of understanding of the TDD process.  When making changes, start from your test.  Change the test for what the new code should do, and make the change.  If that change breaks other tests, then your tests are doing what their supposed to do, failing.  Unit Tests, for me, are designed to fail, hence why the RED stage is first, and should never be missed.</p>\n'}, {'answer_id': 72397, 'author': 'ddaa', 'author_id': 11549, 'author_profile': 'https://Stackoverflow.com/users/11549', 'pm_score': 3, 'selected': False, 'text': '<p>IMHO The biggest misconception about TDD is that: <strong>time spent writing and refactoring tests would be time lost.</strong> The thinking goes like "yeah, a test suite is nice, but the feature would be complete much faster if we just coded it".</p>\n\n<p>When done properly, time spend writing and maintaining tests is saved multiple times over the life of the project in time <em>not</em> spent debugging and fixing regressions. Since the testing cost is up-front and the payoff is over time, it is easy to overlook.</p>\n\n<p>Other big misconceptions include ignoring the impact of TDD on the design process, and not realizing that "painful tests" is a serious code smell that needs fixing quickly.</p>\n'}, {'answer_id': 5632686, 'author': 'superluminary', 'author_id': 687677, 'author_profile': 'https://Stackoverflow.com/users/687677', 'pm_score': 0, 'selected': False, 'text': "<p>Just chucking another answer in the pot.</p>\n\n<p>One of the most common misunderstandings is that your <strong>code is fixed</strong>, ie. I have this code, now how on earth will I test it? If it's hard to write a test, we should ask the question: how can I change this code to make it easier to test? </p>\n\n<p><strong>Why..?</strong></p>\n\n<p>Well The sort of code that's easy to test is:</p>\n\n<ol>\n<li>Modular - each method does one thing.</li>\n<li>Parameterised - each method accepts everything it needs and outputs everything it should.</li>\n<li>Well Specified - each method does exactly what it should, no more, no less.</li>\n</ol>\n\n<p>If we write code like this, testing is a doddle. The interesting thing is that code that is easy to test is, coincidentally, <strong>better code</strong>. </p>\n\n<p>Better as in easier to <strong>read</strong>, easier to <strong>test</strong>, easier to <strong>understand</strong>, easier to <strong>debug</strong>. This is why TDD is often described as a design exercise.</p>\n"}]
['https://Stackoverflow.com/questions/72123', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11979/']