论文标题
Python的自动化单元测试生成
Automated Unit Test Generation for Python
论文作者
论文摘要
自动化单元测试生成是一个既定的研究领域,并且存在用于静态键入编程语言(例如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.