paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications

针对未确定规约上错误假设的 flaky 测试的领域特定修复
ICSE 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE)2021匹配度 2/10 · 该论文研究测试中对未确定规约的错误假设的自动修复(如HashMap迭代顺序),属于软件测试与自动程序修复,与用户核心关注的静态分析、LLM/Agent、浮点程序分析和贝叶斯程序分析均无直接交叉。引用 29 inbox
Peilun Zhang, Yanjie Jiang, Anjiang Wei, Victoria Stodden, Darko Marinov, August Shi
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 DexFix,自动修复测试中对未确定规约的错误假设,如 HashMap/HashSet 迭代顺序依赖。

库开发者常为类和方法提供未确定(underdetermined)的规约,以允许未来实现变化;但库用户代码可能依赖具体实现细节,例如错误假设元素顺序不变,从而产生 flaky 测试。现有 NonDex 方法能检测此类错误假设,但不能修复。本文提出 DexFix,一种自动修复未确定规约上错误假设的方法。作者在 200 个开源 Java 项目上运行 NonDex,检测出 275 个因错误假设而失败的测试,其中多数来自遍历 HashMap/HashSet 集合以及调用 getDeclaredFields 方法。DexFix 提供多种新的修复策略,可在测试代码和主代码中修复这些违规。DexFix 为 275 个检测到的测试中的 119 个提出修复方案。作者已将其中 102 个修复作为 GitHub pull request 提交:74 个被合并,仅 5 个被拒绝,其余仍在处理中。

问题
库的未确定规约允许实现灵活变化,但用户代码常错误依赖具体实现细节(如 HashMap 迭代顺序),导致 flaky 测试;已有 NonDex 只能检测而不能自动修复。
方法
提出 DexFix,在 NonDex 检测基础上,针对 HashMap/HashSet 迭代顺序和 getDeclaredFields 等常见违规模式,提供多种领域特定修复策略,同时可修改测试代码与主代码。
评估
在 200 个开源 Java 项目上运行 NonDex 检测出 275 个失败测试,DexFix 为其中 119 个提出修复;将 102 个修复提交为 GitHub pull request,74 个被合并,仅 5 个被拒。
原文摘要(Abstract)

Library developers can provide classes and methods with underdetermined specifications that allow flexibility in future implementations. Library users may write code that relies on a specific implementation rather than on the specification, e.g., assuming mistakenly that the order of elements cannot change in the future. Prior work proposed the NonDex approach that detects such wrong assumptions. We present a novel approach, called DexFix, to repair wrong assumptions on underdetermined specifications in an automated way. We run the NonDex tool on 200 open-source Java projects and detect 275 tests that fail due to wrong assumptions. The majority of failures are from iterating over HashMap/HashSet collections and the getDeclaredFields method. We provide several new repair strategies that can fix these violations in both the test code and the main code. DexFix proposes fixes for 119 tests from the detected 275 tests. We have already reported fixes for 102 tests as GitHub pull requests: 74 have been merged, with only 5 rejected, and the remaining pending.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{ZhangJWSMS21,
  title = {Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications},
  author = {Peilun Zhang and Yanjie Jiang and Anjiang Wei and Victoria Stodden and Darko Marinov and August Shi},
  booktitle = {ICSE},
  year = {2021},
  doi = {10.1109/icse43902.2021.00018}
}