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

Python单元测试自动生成的实证研究

An Empirical Study of Automated Unit Test Generation for Python

Stephan Lukasczyk, Florian Kroiß, Gordon Fraser

摘要:

对于诸如Java之类的静态类型程序设计语言,存在各种成熟的自动化测试生成工具。然而,由于Python等动态类型化程序设计语言的动态特性以及类型信息的缺乏,自动生成这些语言的单元测试要困难得多。我们的Pynguin框架为Python提供了自动化的单元测试生成。在本文中,我们扩展了我们以前在Pynguin上的工作,以支持Python语言的更多方面,并通过研究各种成熟的最先进的测试生成算法,即DynaMOSA,MIO和MOSA。此外,我们改进了Pynguin工具来生成回归断言,我们还评估了其质量。我们的实验证实,进化算法在Python环境中也可以优于随机测试生成,与Java世界类似,DynaMOSA产生最高的覆盖率结果。然而,我们的结果也表明,仍然存在一些基本的遗留问题,例如在没有这些信息的情况下推断代码的类型信息,目前限制了Python测试生成的有效性。

英文摘要:

Various mature automated test generation tools exist for statically typed programming languages such as Java. Automatically generating unit tests for dynamically typed programming languages such as Python, however, is substantially more difficult due to the dynamic nature of these languages as well as the lack of type information. Our Pynguin framework provides automated unit test generation for Python. In this paper, we extend our previous work on Pynguin to support more aspects of the Python language, and by studying a larger variety of well-established state of the art test-generation algorithms, namely DynaMOSA, MIO, and MOSA. Furthermore, we improved our Pynguin tool to generate regression assertions, whose quality we also evaluate. Our experiments confirm that evolutionary algorithms can outperform random test generation also in the context of Python, and similar to the Java world, DynaMOSA yields the highest coverage results. However, our results also demonstrate that there are still fundamental remaining issues, such as inferring type information for code without this information, currently limiting the effectiveness of test generation for Python.

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

↑