Measuring the Influence of Incorrect Code on Test Generation
Not on the map. Why?
Abstract (arXiv)
It is natural to suppose that a Large Language Model is more likely to generate correct test cases when prompted with correct code under test, compared to incorrect code under test. However, the size of this effect has never been previously measured, despite its obvious importance for both practicing software engineers and researchers. To answer the question, we conducted a comprehensive empirical study on 5 open source and 6 closed source language models, with 3 widely-used benchmark data sets together with 41 repo-level real-world examples from two different real-world data sets. Our results reveal that, when compared to incorrect code under test, LLMs prompted with correct code achieve improvements in test accuracy, code coverage, and bug detection of 57%, 12%, and 24% respectively. We further show that these scientific conclusions carry over from the three benchmark data sets to the real-world code, where tests generated for incorrect code experience a 47% worse bug detection rate. Finally, we report that improvements of +18% in accuracy, +4% coverage, and +34% in bug detection can be achieved by providing natural language code descriptions. These findings have actionable conclusions. For example, the 47% reduction in real-world bug detection is a clear concern. Fortunately, it is a concern for which our findings about the added value of descriptions offer an immediately actionable remedy.
Key facts. Cited by 9 papers in the map (data through 7 Oct 2026). Builds on 37 of its 76 references that are in the map. First posted on arXiv 14 Sep 2024.
Builds on
37 of 76 references.
References · 37
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,193
- 2023MetaGPT: Meta Programming for A Multi-Agent Collaborative Frameworkcited by 1,761
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2023Teaching Large Language Models to Self-Debugcited by 963
- 2024OpenHands: An Open Platform for AI Software Developers as Generalist Agentscited by 956
25 more
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 191
- 2022Few-shot training LLMs for project-specific code-summarizationcited by 128
- 2024Debug like a Human: A Large Language Model Debugger via Verifying Runtime Execution Step-by-stepcited by 123
- 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
- 2022Large Language Models are Zero-Shot Fuzzers: Fuzzing Deep-Learning Libraries via Large Language Modelscited by 102
- 2018Can Neural Machine Translation be Improved with User Feedback?cited by 71
- 2024EffiBench: Benchmarking the Efficiency of Automatically Generated Codecited by 62
- 2023CodeChain: Towards Modular Code Generation Through Chain of Self-revisions with Representative Sub-modulescited by 58
- 2023Bias Testing and Mitigation in LLM-based Code Generationcited by 53
- 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
- 2023ALGO: Synthesizing Algorithmic Programs with LLM-Generated Oracle Verifierscited by 41
- 2024BugsInPy: A Database of Existing Bugs in Python Programs to Enable Controlled Testing and Debugging Studiescited by 35
- 2024EffiLearner: Enhancing Efficiency of Generated Code via Self-Optimizationcited by 28
- 2024Large Language Models as Test Case Generators: Performance Evaluation and Enhancementcited by 27
- 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 25
- 2021CoDesc: A Large Code-Description Parallel Datasetcited by 23
- 2021Type4Py: Practical Deep Similarity Learning-Based Type Inference for Pythoncited by 19
- 2024On Evaluating the Efficiency of Source Code Generated by LLMscited by 19
- 2019An Experience Report On Applying Software Testing Academic Results In Industry: We Need Usable Automated Test Generationcited by 4
- 2023Prompting Code Interpreter to Write Better Unit Tests on Quixbugs Functionscited by 3
Built on by
Citing papers per year: 2024: 1; 2025: 3; 2026: 5.
9 papers.
- 2025EffiBench-X: A Multi-Language Benchmark for Measuring Efficiency of LLM-Generated Codecited by 24
- 2025Afterburner: Reinforcement Learning Facilitates Self-Improving Code Efficiency Optimizationcited by 14
- 2025Scoring Verifiers: Evaluating Synthetic Verification for Code and Reasoningcited by 8
- 2024Design choices made by LLM-based test generators prevent them from finding bugscited by 2
- 2026Inferring Code Correctness from Specificationcited by 0
- 2026Mastermind: Strategy-grounded Learning for Repository-Scale Vulnerability Reproductioncited by 0
- 2026Do Coverage and Mutation Scores of LLM-Generated Test Suites Correlate with Their Effectiveness? (Replicability Study)cited by 0
- 2026Evaluating and Mitigating the Misguidance Effect of Buggy Code in LLM-Generated Unit Testscited by 0
- 2026Validation Evidence in LLM Repair Agents: How Much of What Passes Actually Tests the Bug?cited by 0
- 2026Validation Evidence in LLM Repair Agents: How Much of What Passes Actually Tests the Bug?30 Jul 2026
- 2026Evaluating and Mitigating the Misguidance Effect of Buggy Code in LLM-Generated Unit Tests24 Jul 2026
- 2026Do Coverage and Mutation Scores of LLM-Generated Test Suites Correlate with Their Effectiveness? (Replicability Study)24 Jul 2026
- 2026Mastermind: Strategy-grounded Learning for Repository-Scale Vulnerability Reproduction2 Jul 2026
- 2026Inferring Code Correctness from Specification28 May 2026
- 2025Afterburner: Reinforcement Learning Facilitates Self-Improving Code Efficiency Optimization29 May 2025
- 2025EffiBench-X: A Multi-Language Benchmark for Measuring Efficiency of LLM-Generated Code19 May 2025
- 2025Scoring Verifiers: Evaluating Synthetic Verification for Code and Reasoning19 Feb 2025
- 2024Design choices made by LLM-based test generators prevent them from finding bugs18 Dec 2024