一句话:提出 DAT 测试异味,并用程序分析自动检测与重构为聚焦测试及参数化单元测试。
论文刻画了一种新的测试代码异味——Disjoint Assertion Tangle(DAT),即单个测试方法验证多个逻辑上无关、可分离的行为。作者提出基于程序分析的自动检测与重构方法,实现工具 U2W:先解开 DAT 测试为多个聚焦测试,再将结构相似测试编织为紧凑的参数化单元测试(PUT),以减少冗余并提升可读性、可维护性和故障定位能力。评估包括:在 49 个开源项目的 42,334 个测试上做定量研究,95.9% 项目存在 DAT,平均影响 8.59% 测试;共重构 3,638 个异味测试,拆解为 31,837 条测试执行逻辑,并将 14,343 条织入 1,713 个 PUT,异味测试可执行代码行平均减少 36.33%。49 名参与者的用户调查偏好重构版本;提交 19 个 PR,16 个被接受。
In this work, we characterize a novel test-code smell—Disjoint Assertion Tangle (DAT)—which occurs when a test method verifies multiple, logically unrelated behaviors that can be separated. We propose a program analysis-based approach that automatically detects DAT and refactors DAT tests into separate focused test methods. We implemented this approach as a tool called U2W. By separating unrelated testing logic, U2W enhances readability, maintainability, and fault localization, while exposing hidden test clones and duplicated code. It then seizes these opportunities by converting structurally similar tests into compact, parameterized unit tests (PUTs), reducing redundancy and enabling more scalable, extensible test designs. To evaluate our approach and tool, we conducted a number of evaluations: (1) a large-scale, quantitative study to study the prevalence of the test smell and the effects of their refactoring, (2) a user survey to assess developers’ opinions and preferences of the unrefactored and refactored test code, and (3) pull requests that were issued to original project maintainers to assess the acceptability of our refactorings. Our quantitative study was conducted on 42,334 tests across 49 open-source projects. We found the DAT smell in 95.9% of the subject projects, affecting an average of 8.59% of analyzed tests. In total, we identified and refactored 3,638 smelly tests, untangled them into 31,837 test-execution logics, and then weaved 14,343 of them into 1,713 extensible PUT methods. These refactorings reduced the executable test-code lines in smelly tests by an average of 36.33%. Our user survey involving 49 industrial and academic participants demonstrated strong preference for our refactored test cases over their original, unrefactored versions. Additionally, we submitted 19 pull requests based on our automated refactorings; 16 of these were accepted by project maintainers. These results suggest that U2W effectively improves test-suite quality, and validate our novel test smell aligns closely with developers’ intuitions and practices.
DOI 原文 ·
@inproceedings{paperbot9578,
title = {What’s DAT Smell? Untangling and Weaving the Disjoint Assertion Tangle Test Smell},
author = {Monil Narang and Hang Du and James A. Jones},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00108}
}