Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best argument to convince developers to learn TDD?

Let me first come out of closet. I'm a TDD believer. I'm trying to practice Test Driven Development as much as I can.

Some developers at my work refuse to even try it. I myself started TDD by trying to prove to one of my peers that Test Driven Development is a bad idea. The arguments are:

  • Why? I was pretty successful developer so far.
  • It's going to slow me down.

What's the best pro TDD argument did hear or used?


See also: What is the best reason for unit testing?

like image 753
Vadim Avatar asked May 27 '09 00:05

Vadim


People also ask

How is TDD beneficial to developers?

Developers have less debugging to doFewer bugs and errors are the primary benefit of the TDD approach. When the code has fewer bugs, you'll spend less time fixing them than other programming methodologies. TDD produces a higher overall test coverage and, therefore to a better quality of the final product.

What is the importance of TDD over the?

Not only does TDD save time on fixing bugs, it also means that the cost to change functionality is less, because the tests act as a safety net that ensure your changes won't break existing functionality.

What are three benefits of test-driven development?

Save project costs in the long run The solution will be reliable for any further enhancements or development. You will have ready documentation that can be used further on for any purposes. The quality of the product developed with TDD is significantly higher.

Is TDD a best practice?

Test-driven development is a perfect choice for functional testing but may not be sufficient when it comes to complex situations such as with UI testing. TDD, if understood properly, is the simplest way to achieve high test coverage and better code quality.


1 Answers

Perhaps they know better.

Unit testing by developers is an extremely useful practice and I cannot overemphasize its benefits, not only during initial development but also during refactoring when unit tests can catch early not only ordinary code defects but also the break of assumptions made by developers that were never captured in formal documentation and thus are likely lost by the time refactoring occurs.

That being said, TDD is no magic pixie dust:

  1. the 'just write enough code to pass the test' approach gives false positives. There are often known fallacies and problems that the 'just enough' approach fails to address. Quick examples that come to mind are distributed systems fallacies or NUMA performance problems. Just capturing those requirements into simply expressing those test cases for TDD would turn into a full time job in itself.
  2. the explosion of moqs goes out of control for any serious size project. mocks are code like any other code, they need to be maintained and just don't write themselves out of the blue.
  3. TDD is often used as an excuse to eliminate QA testing. 'our developer have already written tested id, lets ship it' neglects completely the end-to-end feature oriented testing QA should cover
  4. I don't trust the fox guarding the hen house. A wrong algorithm can still pass TDD with flying colors if the same mistakes are made in both the test and in the implementation.
  5. All methodologies in the end try to use process to substitute talent.

My main quarrel with TDD is that is presented as a magic solution to most development problems but its cost is kept under the table by its advocates. Doubling or tripling your code base with moqs does not come for free. I much rather see a few comprehensive unit tests written during development. The test-first TDD approach, I'm yet to see its benefits in a real size project.

I understand I'll be egg-ed to death now for posting this, but what the heck, who cares...

like image 124
Remus Rusanu Avatar answered Sep 29 '22 20:09

Remus Rusanu