arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.05223cs.SE
收藏

自动测试生成工具会生成不稳定测试吗?

Do Automatic Test Generation Tools Generate Flaky Tests?

Martin Gruber, Muhammad Firhard Roslan, Owain Parry, Fabian Scharnböck, Phil McMinn, Gordon Fraser

AI总结:

本研究针对自动测试生成工具产生不稳定测试的普遍性与特性尚不明确的问题,通过对数千个Java、Python项目用对应工具生成测试并多次执行,发现生成测试的不稳定性普遍,现有抑制机制可有效缓解,且成因与开发者编写的测试存在差异,为工具改进和相关研究提供基础。

摘要:

测试行为的不确定性(即不稳定性)在开发者中十分常见且令人头疼。研究人员已对该问题展开研究并提出了缓解方法,但以往绝大多数研究仅关注开发者编写的测试,测试生成工具产生的不稳定测试的普遍性与特性在很大程度上仍不明确。我们探究此类工具是否也会生成不稳定测试,以及这些测试与开发者编写的测试有何差异,此外还评估了抑制不稳定测试生成的机制。我们抽取了6356个用Java或Python编写的项目,针对每个项目,使用EvoSuite(适用于Java)和Pynguin(适用于Python)生成测试,并将每个测试执行200次以查找不一致的结果。结果表明,生成测试中的不稳定性至少与开发者编写的测试中一样普遍。不过,EvoSuite中内置的现有不稳定性抑制机制可有效缓解该问题(不稳定测试数量减少71.7%)。与开发者编写的不稳定测试相比,生成的不稳定测试的成因分布有所不同,其不确定性行为更常由随机性导致,而非网络和并发问题。启用不稳定性抑制后,剩余的不稳定测试与此前报告的任何不稳定性情况都存在显著差异,其中大部分可归因于运行时优化和EvoSuite内部的资源阈值。这些见解及配套数据集可帮助维护者改进测试生成工具,为使用这些工具的开发者提供建议,并为未来测试不稳定性或测试生成领域的研究奠定基础。

英文摘要:

Non-deterministic test behavior, or flakiness, is common and dreaded among developers. Researchers have studied the issue and proposed approaches to mitigate it. However, the vast majority of previous work has only considered developer-written tests. The prevalence and nature of flaky tests produced by test generation tools remain largely unknown. We ask whether such tools also produce flaky tests and how these differ from developer-written ones. Furthermore, we evaluate mechanisms that suppress flaky test generation. We sample 6 356 projects written in Java or Python. For each project, we generate tests using EvoSuite (Java) and Pynguin (Python), and execute each test 200 times, looking for inconsistent outcomes. Our results show that flakiness is at least as common in generated tests as in developer-written tests. Nevertheless, existing flakiness suppression mechanisms implemented in EvoSuite are effective in alleviating this issue (71.7 % fewer flaky tests). Compared to developer-written flaky tests, the causes of generated flaky tests are distributed differently. Their non-deterministic behavior is more frequently caused by randomness, rather than by networking and concurrency. Using flakiness suppression, the remaining flaky tests differ significantly from any flakiness previously reported, where most are attributable to runtime optimizations and EvoSuite-internal resource thresholds. These insights, with the accompanying dataset, can help maintainers to improve test generation tools, give recommendations for developers using these tools, and serve as a foundation for future research in test flakiness or test generation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑