3 ms·
TDD requires you write the test first, then the code later. At an extreme you would write a test for a minimal piece of functionality, then do the minimal amoun
by bbcbasic 12y ago
TDD requires you write the test first, then the code later. At an extreme you would write a test for a minimal piece of functionality, then do the minimal amount of coding to get the test to pass and then repeat. I.e. you would write no production code that is not covered by a test.
This takes a lot of discipline and I have never done it a t work but it is fun to try at home to see what the extreme case is like. I don't do this at work because I have no control over 99.99% of the production code and how loosely coupled it is for testing. (In C#, but in Ruby you can get away with it due to duck typing).
TDD forces you to write code that is testable. So you never should end up thinking 'oh shit I need to expose that private member variable to make this class testable'.
Anyway just try it and then as you get stuck read up on how to do TDD. I am always an advocate of try before you learn (makes the learning easier).