一句话:提出 Testora,首个对比代码变更意图与行为差异来检测回归的自动化方法。
代码变更可能引入回归缺陷或非预期行为。传统回归测试生成将所有行为差异都报为潜在回归,无法区分有意与无意变更。本文提出 Testora,首个对比代码变更意图与行为差异来检测回归的自动化方法。给定一个 pull request,Testora 用 LLM 生成执行修改代码的测试,比较原始与修改后代码的行为,并基于 PR 的自然语言信息(标题、描述、提交信息)用 LLM 将行为差异分类为有意或无意,从而以自然语言意图检测回归。在流行 Python 项目 PR 上,发现 19 个回归缺陷和 11 个意外修复;报告的 13 个回归中 11 个确认、9 个已修复;每 PR 检查 12.3 分钟,LLM 成本 $0.003。
As software is evolving, code changes can introduce regression bugs or affect the behavior in other unintended ways. Traditional regression test generation is impractical for detecting unintended behavioral changes, because it reports all behavioral differences as potential regressions. However, most code changes are intended to change the behavior in some way, e.g., to fix a bug or to add a new feature. This paper presents Testora, the first automated approach that detects regressions by comparing the intentions of a code change against behavioral differences caused by the code change. Given a pull request (PR), Testora queries an LLM to generate tests that exercise the modified code, compares the behavior of the original and modified code, and classifies any behavioral differences as intended or unintended. For the classification, we present an LLM-based technique that leverages the natural language information associated with the PR, such as the title, description, and commit messages – effectively using the natural language intent to detect behavioral regressions. Applying Testora to PRs of complex and popular Python projects, we find 19 regression bugs and 11 PRs that, despite having another intention, coincidentally fix a bug. Out of 13 regressions reported to the developers, 11 have been confirmed and 9 have already been fixed. The costs of using Testora are acceptable for real-world deployment, with 12.3 minutes to check a PR and LLM costs of only $0.003 per PR. We envision our approach to be used before or shortly after a code change gets merged into a code base, providing a way to early on detect regressions that are not caught by traditional approaches.