一句话:ChaosAPI 通过系统扰动 Java 标准库中非确定性 API 的行为,主动检测多种类型的不稳定测试。
回归测试中不稳定测试(flaky tests)会使测试结果不可靠,因此需要尽早主动检测。已有方法要么只针对特定类型的不稳定测试,要么依赖 AI 预测而分析不精确。本文提出 ChaosAPI,其核心思想是直接针对导致测试不稳定的非确定性来源:Java 标准库中与系统时间、并发、环境因素等相关的 API。在测试执行期间,ChaosAPI 以符合 API 规范的方式系统性地扰动这些 API 调用的输入与返回值,并通过观察原本通过的测试是否失败来检测不稳定测试。作者在已知不稳定测试数据集及多个流行开源项目的测试套件上进行了评估,结果表明 ChaosAPI 不仅能比简单重复运行在更广的项目范围内检测到更多不稳定测试,而且检测效率更高,是实用且有效的不稳定测试检测工具。
Regression testing is an essential part of software development to ensure high-quality software; but the presence of flaky tests makes the testing outcomes unreliable. It is essential to proactively detect flaky tests, so developers are aware of them early on and can react appropriately in case they fail. While there has been prior work in detecting flaky tests, they either are developed to focus on specific flaky test types or can be imprecise in their analyses, such as by relying on AI models for prediction. We present ChaosAPI, a framework to support detecting a variety of different types of flaky tests. Our insight is that the most effective approach to detecting flaky tests is to target the nondeterministic components that lead tests to have the flaky behavior in the first place. In particular, we target specific APIs within the Java Standard Library that all Java code relies on and that are known to exhibit nondeterministic behavior, such as those related to system time, concurrency, and environmental factors. During test execution, ChaosAPI modifies the behavior of these API calls, perturbing inputs and return values of these APIs in a systematic manner while still remaining compliant with the API specification. We can detect flaky tests by observing whether tests that previously passed would now fail when run through ChaosAPI. Our evaluation on a prior dataset of known flaky tests, as well as running on test suites of other popular open-source projects, demonstrates that ChaosAPI not only detects more flaky tests than simple rerunning across a wide range of projects but also detects them more efficiently, making ChaosAPI a practical addition to the toolbox of flaky test detection techniques.
@article{paperbot3827,
title = {Detecting Flaky Tests by Controlling Nondeterministic API Behavior},
author = {Hengchen Yuan and Jiefang Lin and August Shi},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {OOPSLA1},
year = {2026},
doi = {10.1145/3798265}
}