An Empirical Study of Automated Unit Test Generation for Python

Stephan Lukasczyk, Florian Kroiß, Gordon Fraser
11/9/2021
cs.SE

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

Abstract

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.

Show full abstract

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.

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{lukasczyk2021empirical,
  title  = {An Empirical Study of Automated Unit Test Generation for Python},
  author = {Stephan Lukasczyk and Florian Kroiß and Gordon Fraser},
  year   = {2021},
  eprint = {2111.05003},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2111.05003}
}

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/2111.05003.svg)](https://codeofpaper.com/paper/2111.05003)

Discussion