volume_mute

Refactoring in TDD

publish date2026/06/18 05:45:7.865879 UTC

volume_mute

After all tests pass in a TDD cycle, the developer is expected to refactor the code. What is the purpose of this refactoring step?

Correct Answer

To improve the structure and clarity of the code without changing its external behavior

Explanation

The refactoring step in TDD aims to improve the internal structure and clarity of the code without changing its external behavior (and therefore without breaking any tests). Because the test suite provides a safety net, developers can refactor confidently - any regression introduced by refactoring will immediately be caught by the existing tests.

Reference

Software Engineering, Ian Sommerville, 10th edition


Quizzes you can take where this question appears