Re-factoring code seems to be the more time consuming area of TDD, is there a way of knowing if you have spent too much time doing so? Or maybe a way of limiting the amount of re-factoring that must be done in order to continue testing?

  • If a question is to help with home work, you need to mention it in the question. Commented Nov 25, 2014 at 23:56

1 Answer 1


Short answer: Limit refactoring to "removing duplication". This is Kent Beck's summary of the refactoring step in Test-Driven Development by Example.

Long answer: the time spent refactoring because of TDD is a blessing, not a curse. It's not a problem that TDD's refactoring takes time ... because in many languages refactoring is only possible because of TDD. TDD enables refactoring in an anxiety-free, predictable way. It's an amazing opportunity that doesn't come from other methodologies.

As you advance in your career, and work on problems you've seen before, you'll develop a feel for how much refactoring is necessary, and when.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.