Type-aware LLM-based Regression Test Generation for Python Programs

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Liu, Runlin, Zhang, Zhe, Hu, Yunge, Lin, Yuhang, Gao, Xiang, Sun, Hailong
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866917031011418112
author Liu, Runlin
Zhang, Zhe
Hu, Yunge
Lin, Yuhang
Gao, Xiang
Sun, Hailong
author_facet Liu, Runlin
Zhang, Zhe
Hu, Yunge
Lin, Yuhang
Gao, Xiang
Sun, Hailong
contents Automated regression test generation has been extensively explored, yet generating high-quality tests for Python programs remains particularly challenging. Because of the Python's dynamic typing features, existing approaches, ranging from search-based software testing (SBST) to recent LLM-driven techniques, are often prone to type errors. Hence, existing methods often generate invalid inputs and semantically inconsistent test cases, which ultimately undermine their practical effectiveness. To address these limitations, we present Test4Py, a novel framework that enhances type correctness in automated test generation for Python. Test4Py leverages the program's call graph to capture richer contextual information about parameters, and introduces a behavior-based type inference mechanism that accurately infers parameter types and construct valid test inputs. Beyond input construction, Test4Py integrates an iterative repair procedure that progressively refines generated test cases to improve coverage. In an evaluation on 183 real-world Python modules, Test4Py achieved an average statement coverage of 83.0% and branch coverage of 70.8%, outperforming state-of-the-art tools by 7.2% and 8.4%, respectively.
format Preprint
id arxiv_https___arxiv_org_abs_2503_14000
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Type-aware LLM-based Regression Test Generation for Python Programs
Liu, Runlin
Zhang, Zhe
Hu, Yunge
Lin, Yuhang
Gao, Xiang
Sun, Hailong
Software Engineering
Automated regression test generation has been extensively explored, yet generating high-quality tests for Python programs remains particularly challenging. Because of the Python's dynamic typing features, existing approaches, ranging from search-based software testing (SBST) to recent LLM-driven techniques, are often prone to type errors. Hence, existing methods often generate invalid inputs and semantically inconsistent test cases, which ultimately undermine their practical effectiveness. To address these limitations, we present Test4Py, a novel framework that enhances type correctness in automated test generation for Python. Test4Py leverages the program's call graph to capture richer contextual information about parameters, and introduces a behavior-based type inference mechanism that accurately infers parameter types and construct valid test inputs. Beyond input construction, Test4Py integrates an iterative repair procedure that progressively refines generated test cases to improve coverage. In an evaluation on 183 real-world Python modules, Test4Py achieved an average statement coverage of 83.0% and branch coverage of 70.8%, outperforming state-of-the-art tools by 7.2% and 8.4%, respectively.
title Type-aware LLM-based Regression Test Generation for Python Programs
topic Software Engineering
url https://arxiv.org/abs/2503.14000