DEV Community

Discussion on: What are the Best Tips in implement TDD in a web application project

Collapse
 
n_develop profile image
Lars Richter

I totally agree with Leighton on the book recommendation. "Test-Driven Development by example" from Kent Beck is "the Bible" for TDD. It's great to learn the fundamentals. The fundamentals are important. As Leighton already said: get "Red-Green-Refactor" loaded in your brain.
Code Katas, like the mentioned "String Calculator" or Uncle Bob's "Bowling Game", are good to learn the cycle.

BUT: I think there are some very important techniques you need to know, before you can make use of all the TDD benefits.

Dependency Injection:
It's nice to test your code. But if you want to end up with code that is well designed, you need to understand the concept of dependency injection. If you are comfortable with .NET I recommend this book. For me, this is one of the key concepts for testable and maintainable code.

Know your tools:
You should choose a testing framework. I am a .NET-guy. So I use xUnit.NET a lot. Another choice could be NUnit. These two are the two "big ones" in the .NET world. Of course there is also MSTest, but I could never get used to it.

The next important tool, in my opinion, is an isolation framework. My favorite one is NSubstitute. It is simple to use and creates "easy to read" code.

And in the end your programming language and IDE are tools, too. You should choose a language, that supports unittests in an easy way. Most modern languages are quite OK for that. But, as usual, some of them are more "test-friendly" than others. I checked your profile and it looks like you are familiar with C#. I think it is a reasonable choice.

After you tried TDD on a real project, I would love to hear how it went. Maybe you can join the discussion about the problems with "real world TDD".

Collapse
 
jrking365 profile image
Jean Roger Nigoumi Guiala

Yeah ok thank you,i started looking at dependency injection weeks ago...
Yeah i will definetely join the discussion =D