Reflective Unit Test Generation for Precise Type Error Detection with Large Language Models
Chen Yang, Ziqi Wang, Yanjie Jiang, Lin Yang, Yuteng Zheng, Jianyi Zhou, Junjie Chen
摘要
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, we applied rTED to six real-world open-source Python projects, and successfully discovered 12 previously unknown type errors, demonstrating rTED’s practical value.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 4 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Fuzz4All: Universal Fuzzing with Large Language Models 引用了 CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
- Clarifying Semantics of In-Context Examples for Unit Test Generation 引用了 Efficient Memory Management for Large Language Model Serving with PagedAttention
- Teaching Large Language Models to Self-Debug 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Characterizing and Mitigating False-Positive Bug Reports in the Linux Kernel 引用了 Clarifying Semantics of In-Context Examples for Unit Test Generation
- Characterizing and Mitigating False-Positive Bug Reports in the Linux Kernel 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Context Matters: Improving the Practical Reliability of LLM-Based Unit Test Generation (Experience Paper) 引用了 CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
- Context Matters: Improving the Practical Reliability of LLM-Based Unit Test Generation (Experience Paper) 引用了 Clarifying Semantics of In-Context Examples for Unit Test Generation
- Context Matters: Improving the Practical Reliability of LLM-Based Unit Test Generation (Experience Paper) 引用了 Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper)
- Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper) 引用了 CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
- Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper) 引用了 Fuzz4All: Universal Fuzzing with Large Language Models
- Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper) 引用了 Clarifying Semantics of In-Context Examples for Unit Test Generation
引用它的顶会 Paper4
- Clarifying Semantics of In-Context Examples for Unit Test GenerationChen Yang, Lin Yang, Ziqi Wang, Dong Wang 等ASE 2025 · 1 次引用
- Characterizing and Mitigating False-Positive Bug Reports in the Linux KernelJiashuo Tian, Dong Wang, Chen Yang, Haichi Wang 等FSE 2026
- Context Matters: Improving the Practical Reliability of LLM-Based Unit Test Generation (Experience Paper)Junjie Chen, Ziqi Wang, Lin Yang, Chen Yang 等ISSTA 2026
- Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation (Experience Paper)Chen Yang, Junjie ChenISSTA 2026
它引用的 Paper20
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma 等NeurIPS 2022 · 22,562 次引用
- Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli, Denny ZhouICLR 2024 · 1,085 次引用
- Efficient Memory Management for Large Language Model Serving with PagedAttentionWoosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng 等SOSP 2023 · 1,016 次引用
- CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language ModelsCaroline Lemieux, Jeevana Priya Inala, Shuvendu K. Lahiri, Siddhartha SenICSE 2023 · 221 次引用
- Fuzz4All: Universal Fuzzing with Large Language ModelsChunqiu Steven Xia, Matteo Paltenghi, Jia Le Tian, Michael Pradel 等ICSE 2024 · 155 次引用
相关 Paper
- Towards Effective Static Type-Error Detection for PythonWonseok Oh, Hakjoo OhASE 2024 · 1 次引用
- PyTER: effective program repair for Python type errorsWonseok Oh, Hakjoo OhFSE 2022 · 22 次引用
- Names Are All You Need: Effective and Safe Regression Test Selection for PythonYou Wang, Michael Pradel, Zhongxin LiuISSTA 2026
- PyRTFuzz: Detecting Bugs in Python Runtimes via Two-Level Collaborative FuzzingWen Li, Haoran Yang, Xiapu Luo, Long Cheng 等CCS 2023 · 14 次引用
- The Power of Types: Exploring the Impact of Type Checking on Neural Bug Detection in Dynamically Typed LanguagesBoqi Chen, José Antonio Hernández López, Gunter Mussbacher, Dániel VarróICSE 2025
