Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Yang, Chen, Wang, Ziqi, Jiang, Yanjie, Yang, Lin, Zheng, Yuteng, Zhou, Jianyi, Chen, Junjie
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866911188400472064
author Yang, Chen
Wang, Ziqi
Jiang, Yanjie
Yang, Lin
Zheng, Yuteng
Zhou, Jianyi
Chen, Junjie
author_facet Yang, Chen
Wang, Ziqi
Jiang, Yanjie
Yang, Lin
Zheng, Yuteng
Zhou, Jianyi
Chen, Junjie
contents Type errors in Python often lead to runtime failures, posing significant challenges to software reliability and developer productivity. Existing static analysis tools aim to detect such errors without execution but frequently suffer from high false positive rates. Recently, unit test generation techniques offer great promise in achieving high test coverage, but they often struggle to produce bug-revealing tests without tailored guidance. To address these limitations, we present RTED, a novel type-aware test generation technique for automatically detecting Python type errors. Specifically, RTED combines step-by-step type constraint analysis with reflective validation to guide the test generation process and effectively suppress false positives. We evaluated RTED on two widely-used benchmarks, BugsInPy and TypeBugs. Experimental results show that RTED can detect 22-29 more benchmarked type errors than four state-of-the-art techniques. RTED is also capable of producing fewer false positives, achieving an improvement of 173.9%-245.9% in precision. Furthermore, RTED successfully discovered 12 previously unknown type errors from six real-world open-source Python projects.
format Preprint
id arxiv_https___arxiv_org_abs_2507_02318
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models
Yang, Chen
Wang, Ziqi
Jiang, Yanjie
Yang, Lin
Zheng, Yuteng
Zhou, Jianyi
Chen, Junjie
Software Engineering
Type errors in Python often lead to runtime failures, posing significant challenges to software reliability and developer productivity. Existing static analysis tools aim to detect such errors without execution but frequently suffer from high false positive rates. Recently, unit test generation techniques offer great promise in achieving high test coverage, but they often struggle to produce bug-revealing tests without tailored guidance. To address these limitations, we present RTED, a novel type-aware test generation technique for automatically detecting Python type errors. Specifically, RTED combines step-by-step type constraint analysis with reflective validation to guide the test generation process and effectively suppress false positives. We evaluated RTED on two widely-used benchmarks, BugsInPy and TypeBugs. Experimental results show that RTED can detect 22-29 more benchmarked type errors than four state-of-the-art techniques. RTED is also capable of producing fewer false positives, achieving an improvement of 173.9%-245.9% in precision. Furthermore, RTED successfully discovered 12 previously unknown type errors from six real-world open-source Python projects.
title Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models
topic Software Engineering
url https://arxiv.org/abs/2507.02318