Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the limits of TDD? [closed]

Tags:

tdd

I have just recently discovered how much I enjoy developing code the TDD way: I feel I have much more control over the direction the development is going. Whereas before I spent a lot of time designing data structures and algorithms up front, now I start small and "grow" my code organically. After every red/green/refactor cycle I have code that does something. It feels like my code is a living thing and I am directing where it should grow. I don't know if that's how everyone feels when they get into TDD, but this is my experience. And it strikes me that this is so similar to how successful free software projects are grown rather than designed.

However, now that I have got a hang on the test-driven development, I am beginning to wonder what its limits are. It seems to be quite useful for developing functional code: feed this input to that function, and you get this result. But this is just a small part of what software development is about. What about GUI development, networking, database development, web applications? What is your experience? Have you ever tried TDD with any of these types of development? Do you know of any tools or frameworks? Can you recommend any articles or books?

like image 912
ajanicij Avatar asked Apr 23 '09 13:04

ajanicij


2 Answers

"What about GUI development, networking, database development, web applications?"

Why wouldn't it work?

GUI. The only thing TDD can't do well is evaluate the "look" of the interface. But it can evaluate the behavior. If you did your design well (separating model, view and control), you can test the control and model easily as TDD. view, however, is more difficult to write tests for. ("assert that the button is below the field" isn't sensible.)

Networking. Not sure what this means. However, defining RESTful web services works out very nicely when done via TDD. Define the URI's, write test cases, and then build the services that provide expected responses.

Web Applications. The Django web framework directly supports TDD for development. They have unit tests for the web data model and control layers. Plus, they have unit tests for the HTML page presentation and behavior.

like image 76
S.Lott Avatar answered Oct 19 '22 05:10

S.Lott


I am wondering what framework/language you use for your TDD if you have not yet hit the most obvious parts of where it is difficult:

  • GUIs - Certain environments and platforms, specifically, Windows Forms and ASP.NET web forms, suffer from practical untestability, because there is no easy way to isolate or mock their behavior. This is one of the main driving forces of ASP.NET MVC, for that matter.

  • Persistence - Any sort of persistence, whether it be disk storage, connection to a database, to a network, or some other form of external system would be a limitation, as all of them are persistence tests which depend too much on the state of an external component to succeed. These integration tests then are considered fragile tests. Mocking is used to mitigate the impact of such external systems.

  • Adoption - Even if you are well versed in TDD, it's an uphill battle trying to get other developers -- much less whole development shops -- to use it. Many just don't see the benefit; they are easily turned off by the initial steep learning and productivity curves. You will encounter cases wherein you're the only one practicing TDD in your project and even if you enforce it the other developers will introduce low-quality, senseless tests. This non-technical reason is the biggest hurdle to using TDD in real-life production systems that I have faced, and it's a painful realization when you're quite aware of the benefits.

like image 36
Jon Limjap Avatar answered Oct 19 '22 05:10

Jon Limjap