一句话:实证评估 Gemini-2.5-Pro 以单/多智能体工作流检测并重构五类测试坏味,单智能体正确率达 75%,多智能体收益有限。
测试坏味是测试代码中反复出现的设计症状,可能影响可维护性与可读性,但现有多数方法只做检测、鲜有自动化移除。本文评估 Gemini-2.5-Pro 在检测与重构五类常见测试坏味上的表现,在 200 个 JUnit 5 测试上比较单智能体、双智能体与四智能体工作流。在单智能体 pass@1 设置下,模型正确检测并重构了 75%(150/200)的用例;多智能体工作流将短测试的检测率提升至 83%,但重构收益边际且成本更高。作者还对 50 名开发者开展调研,将原始测试片段与 Phi-4-14B 生成的重构版本并排展示,约 66% 的对比中开发者更偏好重构版本。
Test smells are recurring design symptoms that may indicate potential issues in test maintenance and readability, rather than immediate functional failures. Although many approaches detect these issues, few automate their removal. This study evaluates how Gemini-2.5-Pro performs in detecting and refactoring five common test smells using one-, two-, and four-agent workflows across 200 JUnit 5 tests. Under a single-agent pass@1 setting, Gemini-2.5-Pro correctly detected and refactored 75% (150/200) of cases. While multi-agent workflows improved short-test detection to 83%, they yielded marginal refactoring gains and higher costs. We also conducted a complementary survey with 50 developers, presenting each original test snippet alongside a Phi-4-14B-generated refactoring; the refactored version was preferred in about 66% of the comparisons.