Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I opt for test driven development?

Tags:

tdd

My question is same as the title. I have not done Test driven development yet,I have performed unit testing and I am aware of testing in general but I hear it is much advantageous to follow TDD?. So should I opt for it everytime or are there some preconditions... i just need to know some basic or important requirements when i should opt for TDD. Sorry if this question is too trivial.

like image 496
Vishal Avatar asked Dec 23 '22 02:12

Vishal


2 Answers

I would say whenever you are coding for a project. By this I mean where you are hoping to produce code that will be used by people. This is basically all code apart from research where you are learning and discovering new techniques.

Even if you think the project is just a small one often things spiral up out of control without care. You wil be glad for the tests when you find yourself having to refactor a big sprawl of code.

Also note that tdd isn't just about testing. It is a methodology of development that encourages you to create clean and solid designs.

As you are starting out tdd everything. Once you have more experience then perhaps you can back off and determine when to not tdd.

like image 73
Mongus Pong Avatar answered Dec 24 '22 16:12

Mongus Pong


IMHO if you are not comfortable with TDD, trying to apply it in projects where you will need to interact/use legacy code it's much more complex than applying it in a project from scratch. In fact, there is a whole book about this.

HTH

like image 41
Marcote Avatar answered Dec 24 '22 17:12

Marcote