lundi 25 avril 2016

How to implement TDD (Test Driven Development)?

I have recently began my career as a Software Engineer, and one of the concepts my team has introduced to me is TDD.

I understand the concept and why it is awesome, but I am having trouble implementing it since at the enterprise level I do not see any standardized testing procedures. I am not sure which way is the right way of implementing TDD. I have gone through many guides and tutorials but still feel stuck.

My main question is: what is the correct way of implementing TDD? Do I write my code first, then immediately test it (i.e. defining a function called add, then asserting outputs)? Or do I write my tests first, run them, and then the code if my tests are correct? I am having a difficult time understanding why I would write tests first as there is no code to test against it. Does this mean I would write my code in my would-be function (i.e. defining my add function in my test case, then testing it, if it works, then port the working code to my application)?

I write code from scratch as well as try to implement new features/debug legacy code. It would be excellent if some examples would be provided as to how this would work. I do take a generalist approach when it comes to development, so I would like to keep this as language-agnostic as possible.

Aucun commentaire:

Enregistrer un commentaire