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

Python中Flaky测试的实证研究

An Empirical Study of Flaky Tests in Python

Martin Gruber, Stephan Lukasczyk, Florian Kroiß, Gordon Fraser

摘要:

在没有任何代码更改的情况下导致虚假故障的测试,即,干扰测试,妨碍回归测试,增加维护成本,可能会隐藏真正的bug,并降低对测试的信任。虽然片状的普遍性和重要性已经得到了很好的证实,但之前的研究主要集中在Java项目上,因此提出了如何推广研究结果的问题。为了提供一个更好的理解,在软件开发中的作用,超越Java的,我们实证研究的流行,原因,和在Python,目前最流行的程序设计语言编写的软件中的flakiness程度。为此,我们从流行的PyPI包索引中抽取了22352个开源项目,并分析了它们的876186个测试用例。我们的调查表明,flakiness在Python中和在Java中一样普遍。然而,原因是不同的:顺序依赖是Python中一个更主要的问题,在我们的数据集中,7571个重复测试中有59%是由顺序依赖引起的。另外28%是由测试基础设施问题引起的,这是以前没有记录的片状原因。剩下的13%主要归因于项目对网络和随机性API的使用,这表明了通常用Python编写的软件类型。我们的数据还表明,找到可重复测试需要比文献中经常做的更多的运行:一个通过测试的案例平均不重复的95%的置信度将需要170次重新运行。

英文摘要:

Tests that cause spurious failures without any code changes, i.e., flaky tests, hamper regression testing, increase maintenance costs, may shadow real bugs, and decrease trust in tests. While the prevalence and importance of flakiness is well established, prior research focused on Java projects, thus raising the question of how the findings generalize. In order to provide a better understanding of the role of flakiness in software development beyond Java, we empirically study the prevalence, causes, and degree of flakiness within software written in Python, one of the currently most popular programming languages. For this, we sampled 22352 open source projects from the popular PyPI package index, and analyzed their 876186 test cases for flakiness. Our investigation suggests that flakiness is equally prevalent in Python as it is in Java. The reasons, however, are different: Order dependency is a much more dominant problem in Python, causing 59% of the 7571 flaky tests in our dataset. Another 28% were caused by test infrastructure problems, which represent a previously undocumented cause of flakiness. The remaining 13% can mostly be attributed to the use of network and randomness APIs by the projects, which is indicative of the type of software commonly written in Python. Our data also suggests that finding flaky tests requires more runs than are often done in the literature: A 95% confidence that a passing test case is not flaky on average would require 170 reruns.

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

↑