paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Testability Refactoring in Pull Requests: Patterns and Trends

Pull Request 中的可测试性重构:模式与趋势
ICSE 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)2023匹配度 2/10 · 该论文属于经验软件工程,研究 Java PR 中为提升可测试性而进行的重构模式与趋势,未涉及 LLM/Agent、静态分析在机器学习或 Agentic 程序中的应用,也未涉及浮点程序分析、贝叶斯程序分析或 LLM 与形式化验证的交叉。仅“程序重构/变换”与 PL 有非常间接的关联,因此匹配度较低。引用 7 inbox
Pavel Reich, Walid Maalei
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:大规模研究 Java PR 中为提升可测试性而进行的复合重构,归纳出十种模式并揭示其趋势。

论文关注为创建单元测试而对生产代码进行的可测试性重构,例如放宽方法访问或拆分类以便独立测试。作者收集了 621 个 GitHub Java 项目中的 346,841 个 PR,首先比较含测试-生产代码协同变更(test-pairs)与不含 test-pairs 的 PR 中原子重构的差异,发现前者显著包含更多如改变变量类型、改变参数类型等操作。其次人工分析 200 个显式提及 testability 或 refactor+test 的 PR,识别出十种可测试性重构模式;又分析 524 个 test-pairs PR。约 25% 的被分析 PR 实际包含这些模式,最常见的是为 override 或 invocation 提取方法、放宽方法访问以供调用、为调用提取类。论文还报告与这些模式共现的原子重构,并讨论对研究、实践与教育的启示。

问题
开发者常需重构生产代码以提升可测试性,但这类复合重构在 pull request 中的实际模式与普遍程度尚缺乏系统认识。
方法
挖掘 621 个 Java 项目的 346,841 个 PR,比较 test-pairs 与非 test-pairs 的原子重构差异,并人工分析 724 个相关 PR 以归纳可测试性重构模式。
评估
通过大规模 PR 挖掘与人工标注,识别出十种可测试性重构模式;约 25% 的被分析 PR 包含这些模式,并总结其高频原子重构共现与趋势。
原文摘要(Abstract)

To create unit tests, it may be necessary to refactor the production code, e.g. by widening access to specific methods or by decomposing classes into smaller units that are easier to test independently. We report on an extensive study to understand such composite refactoring procedures for the purpose of improving testability. We collected and studied 346,841 java pull requests from 621 GitHub projects. First, we compared the atomic refactorings in two populations: pull requests with changed test-pairs (i.e. with co-changes in production and test code and thus potentially including testability refactoring) and pull requests without test-pairs. We found significantly more atomic refactorings in test-pairs pull requests, such as Change Variable Type Operation or Change Parameter Type. Second, we manually analyzed the code changes of 200 pull requests, where developers explicitly mention the terms “testability” or “refactor + test”. We identified ten composite refactoring procedures for the purpose of testability, which we call testability refactoring patterns. Third, we manually analyzed additional 524 test-pairs pull requests: both randomly selected and where we assumed to find testability refactorings, e.g. in pull requests about dependency or concurrency issues. About 25% of all analyzed pull requests actually included testability refactoring patterns. The most frequent were extract a method for override or for invocation, widen access to a method for invocation, and extract a class for invocation. We also report on frequent atomic refactorings which co-occur with the patterns and discuss the implications of our findings for research, practice, and education.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{ReichM25,
  title = {Testability Refactoring in Pull Requests: Patterns and Trends},
  author = {Pavel Reich and Walid Maalei},
  booktitle = {ICSE},
  year = {2023},
  doi = {10.1109/icse48619.2023.00131}
}