Automated Unit Test Generation for Python

Stephan Lukasczyk, Florian Kroiß, Gordon Fraser
7/28/2020
cs.SE

Official code: se2p/pynguin (1,396 stars, Python, MIT, last commit 2026-11-04).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

se2p/pynguinOfficial100%
MIT

The PYthoN General UnIt Test geNerator is a test-generation tool for Python

1,396105Python, FantomJul 27, 20203 weeks agoMIT
pythonsearch-based-software-testingtest-generationtest-generatortesting-tools

Similar Papers

Cite this paper

@article{lukasczyk2020automated,
  title  = {Automated Unit Test Generation for Python},
  author = {Stephan Lukasczyk and Florian Kroiß and Gordon Fraser},
  year   = {2020},
  eprint = {2007.14049},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2007.14049}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2007.14049.svg)](https://codeofpaper.com/paper/2007.14049)

Discussion