The authors of this paper have analyzed three open source libraries (JUnit, Jakarta HTTPClient and Jakarta HTTPCore) to answer different questions related to refactoring.
RQ1 do developers apply the same refactorings to test code as to production code?
In production code, design improvements are made where in tests refactorings are more about reorganization and renaming.
RQ2 Which developers are responsible fro refactorings?
In all three projects there is 1 ‘refactoring manager’ who does the refactorings.
RQ3 Is there more refactorings activity before or after a release?
In all projects there was mayor refactoring activity before the release. This is interesting, as it sort or contradicts the idea that technical debt is often taken before a release, which is then resolved after. But, as the authors themselves admit, this might be due to the fact that these are libraries, so they care more about code quality and (this is my addition not theirs) also because they are largely responsible for their own planning and do not have customers or managers pressing.
RQ4 Is a refactorings on the production code preceded by refactorings of test code?
Yes. Most refactoring takes place during a ‘test phase’.
RQ5 What is the purpose of the refactoring?
The authors found that ‘extract method is the Swiss army knife of refactorings’, it is used for many different purposes, as the table below shows.
As you can see, 44% of uses of extract method was driven bij smell detection, 44% by extension and the remainder for backward compatibility.
The paper is available for download.