<Dd> If all test cases now pass, the programmer can be confident that the new code meets the test requirements, and does not break or degrade any existing features . If they do not, the new code must be adjusted until they do . </Dd> <Dt> 5 . Refactor code </Dt> <Dd> The growing code base must be cleaned up regularly during test - driven development . New code can be moved from where it was convenient for passing a test to where it more logically belongs . Duplication must be removed . Object, class, module, variable and method names should clearly represent their current purpose and use, as extra functionality is added . As features are added, method bodies can get longer and other objects larger . They benefit from being split and their parts carefully named to improve readability and maintainability, which will be increasingly valuable later in the software lifecycle . Inheritance hierarchies may be rearranged to be more logical and helpful, and perhaps to benefit from recognized design patterns . There are specific and general guidelines for refactoring and for creating clean code . By continually re-running the test cases throughout each refactoring phase, the developer can be confident that process is not altering any existing functionality . The concept of removing duplication is an important aspect of any software design . In this case, however, it also applies to the removal of any duplication between the test code and the production code--for example magic numbers or strings repeated in both to make the test pass in Step 3 . </Dd> <Dd> Starting with another new test, the cycle is then repeated to push forward the functionality . The size of the steps should always be small, with as few as 1 to 10 edits between each test run . If new code does not rapidly satisfy a new test, or other tests fail unexpectedly, the programmer should undo or revert in preference to excessive debugging . Continuous integration helps by providing revertible checkpoints . When using external libraries it is important not to make increments that are so small as to be effectively merely testing the library itself, unless there is some reason to believe that the library is buggy or is not sufficiently feature - complete to serve all the needs of the software under development . </Dd>

In v model why test cases are created before code