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

Python单元测试自动生成

Automated Unit Test Generation for Python

Stephan Lukasczyk, Florian Kroiß, Gordon Fraser

摘要:

自动化单元测试生成是一个已建立的研究领域,并且成熟的测试生成工具存在于诸如Java的静态类型化程序设计语言中。然而,由于缺乏类型信息和语言的动态特性,为动态类型的程序设计语言(如Python)自动生成支持测试要困难得多。在本文中,我们描述了一个尝试到动态类型语言的单元测试生成问题。我们介绍Pynguin,一个Python的自动化单元测试生成框架。使用Pynguin,我们的目标是从经验上阐明两个核心问题:(1)建立良好的基于搜索的测试生成方法,以前只评估静态类型的语言,推广到动态类型的语言?(2)不完全类型信息和动态类型对自动化测试生成问题有什么影响?我们的实验证实,进化算法在Python环境中也可以优于随机测试生成,甚至可以在一定程度上缓解缺少类型信息的问题。然而,我们的研究结果表明,动态类型仍然提出了一个根本性的问题,测试生成,建议未来的工作集成类型推断。

英文摘要:

Automated unit test generation is an established research field, and mature test generation tools exist for statically typed programming languages such as Java. It is, however, substantially more difficult to automatically generate supportive tests for dynamically typed programming languages such as Python, due to the lack of type information and the dynamic nature of the language. In this paper, we describe a foray into the problem of unit test generation for dynamically typed languages. We introduce Pynguin, an automated unit test generation framework for Python. Using Pynguin, we aim to empirically shed light on two central questions: (1) Do well-established search-based test generation methods, previously evaluated only on statically typed languages, generalise to dynamically typed languages? (2) What is the influence of incomplete type information and dynamic typing on the problem of automated test generation? Our experiments confirm that evolutionary algorithms can outperform random test generation also in the context of Python, and can even alleviate the problem of absent type information to some degree. However, our results demonstrate that dynamic typing nevertheless poses a fundamental issue for test generation, suggesting future work on integrating type inference.

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

↑