How does TDD make refactoring easier?

前端 未结 8 876
温柔的废话
温柔的废话 2021-02-01 16:53

I\'ve heard that projects developed using TDD are easier to refactor because the practice yields a comprehensive set of unit tests, which will (hopefully) fail if any change has

8条回答
  •  隐瞒了意图╮
    2021-02-01 17:15

    The main benefits of TDD brought to refactor is that developer has more courage to change their code. With unit test ready, developers dare to change code and then just run it. If the xUnit bar is still green, they have confidence to go ahead.

    Personally, I like TDD, but doesn't encourage over-TDD. That is, don't write too much unit test cases. The unit tests should just be enough. If you over unit testing, then you may find you are in a dilemma when you want to do a architecture change. One big change in production code will bring a lot of unit test cases change. So, just keep your unit test enough.

提交回复
热议问题