Hallucination to Consensus: Multi-Agent LLMs for End-to-End JUnit Test Generation
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
Unit testing plays a critical role in ensuring software correctness. However, writing unit tests manually is labor-intensive, especially for strongly typed languages like Java, motivating the need for automated approaches. Traditional methods primarily rely on search-based or randomized algorithms to achieve high code coverage and produce regression oracles, which are derived from the program's current behavior rather than its intended functionality. Recent advances in LLMs have enabled oracle generation from natural language descriptions, aligning better with user requirements. However, existing LLM-based methods often require fine-tuning or rely on external tools such as EvoSuite for test prefix generation, making them costly or cumbersome to apply in practice. In this work, we propose CANDOR, a novel prompt engineering-based LLM framework for automated unit test generation in Java. CANDOR orchestrates multiple specialized LLM agents to collaboratively generate complete tests. To mitigate the notorious hallucinations in LLMs and improve oracle correctness, we introduce a novel strategy that engages multiple reasoning LLMs in a panel discussion and generates accurate oracles based on consensus. Additionally, to reduce the verbosity of reasoning LLMs' outputs, we propose a novel dual-LLM pipeline to produce concise and structured oracle evaluations. Our experiments show that CANDOR is comparable with EvoSuite in generating tests with high code coverage and clearly superior in terms of mutation score. Moreover, our prompt engineering-based approach CANDOR significantly outperforms the SOTA fine-tuning-based oracle generator TOGLL by at least 21.1 percentage points in oracle correctness on both correct and faulty source code. Further ablation studies confirm the critical contributions of key agents in generating high-quality tests.
Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 33 of its 90 references that are in the map. First posted on arXiv 3 Jun 2025.
Builds on
33 of 90 references.
Closest ancestors · 1
Same direction, newest first
Other references · 32
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open Questionscited by 1,601
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 194
- 2022Multi-lingual Evaluation of Code Generation Modelscited by 159
- 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
- 2023ChatUniTest: A Framework for LLM-Based Test Generationcited by 96
- 2024Code-Aware Prompting: A study of Coverage Guided Test Generation in Regression Setting using LLMcited by 64
- 2021TOGA: A Neural Method for Test Oracle Generationcited by 57
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?cited by 57
- 2023Using Large Language Models to Generate JUnit Tests: An Empirical Studycited by 53
- 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
- 2023Explainable Automated Debugging via Large Language Model-driven Scientific Debuggingcited by 40
20 more
- 2024CoverUp: Effective High Coverage Test Generation for Pythoncited by 38
- 2024HITS: High-coverage LLM-based Unit Test Generation via Method Slicingcited by 38
- 2024On the Evaluation of Large Language Models in Unit Test Generationcited by 34
- 2023A3Test: Assertion-Augmented Automated Test Case Generationcited by 33
- 2023ChatGPT vs SBST: A Comparative Assessment of Unit Test Suite Generationcited by 32
- 2023CAT-LM: Training Language Models on Aligned Code And Testscited by 28
- 2024TOGLL: Correct and Strong Test Oracle Generation with LLMscited by 24
- 2024Hybrid Automated Program Repair by Combining Large Language Models and Program Analysiscited by 22
- 2023Reinforcement Learning from Automatic Feedback for High-Quality Unit Test Generationcited by 21
- 2024TestART: Improving LLM-based Unit Testing via Co-evolution of Automated Generation and Repair Iterationcited by 20
- 2023Fixing Large Language Models' Specification Misunderstanding for Better Code Generationcited by 17
- 2023Enhancing Automated Program Repair through Fine-tuning and Prompt Engineeringcited by 10
- 2023Prompt Engineering or Fine-Tuning: An Empirical Assessment of LLMs for Codecited by 9
- 2023Domain Adaptation for Code Model-based Unit Test Case Generationcited by 7
- 2024LLM-based Unit Test Generation via Property Retrievalcited by 6
- 2024UniTSyn: A Large-Scale Dataset Capable of Enhancing the Prowess of Large Language Models for Program Testingcited by 5
- 2024CasModaTest: A Cascaded and Model-agnostic Self-directed Framework for Unit Test Generationcited by 4
- 2020Using mutation testing to measure behavioural test diversitycited by 1
- 2024Evaluating the Dependency Between Cyclomatic Complexity and Response For Classcited by 1
- 2024What You See Is What You Get: Attention-based Self-guided Automatic Unit Test Generationcited by 1
Built on by
Citing papers per year: 2025: 2; 2026: 7.
9 papers.
- 2026Code as Agent Harnesscited by 47
- 2025CATArena: Evaluating Evolutionary Capabilities of Code Agents via Iterative Tournamentscited by 5
- 2025Nexus: Execution-Grounded Multi-Agent Test Oracle Synthesiscited by 4
- 2026Judging Is Not Enumerating: Silent Omissions in LLM-Authored Acceptable Setscited by 2
- 2026FASE: Fast Adaptive Semantic Entropy for Code Qualitycited by 1
- 2026MANGO: Automated Multi-Agent Test Oracle Generation for Vision-Language-Action Modelscited by 1
- 2026SmartOracle -- An Agentic Approach to Mitigate Noise in Differential Oraclescited by 0
- 2026Multi-Large Language Model Orchestrated Severity Assessment of Clinical Records (MOSAIC)cited by 0
- 2026Testing and Evaluation of Agentic AI Systems In Military Command and Controlcited by 0
- 2026Testing and Evaluation of Agentic AI Systems In Military Command and Control20 Aug 2026
- 2026Judging Is Not Enumerating: Silent Omissions in LLM-Authored Acceptable Sets2 Aug 2026
- 2026Multi-Large Language Model Orchestrated Severity Assessment of Clinical Records (MOSAIC)6 Jul 2026
- 2026MANGO: Automated Multi-Agent Test Oracle Generation for Vision-Language-Action Models23 Jun 2026
- 2026FASE: Fast Adaptive Semantic Entropy for Code Quality8 Jun 2026
- 2026Code as Agent Harness18 May 2026
- 2026SmartOracle -- An Agentic Approach to Mitigate Noise in Differential Oracles21 Jan 2026
- 2025CATArena: Evaluating Evolutionary Capabilities of Code Agents via Iterative Tournaments30 Oct 2025
- 2025Nexus: Execution-Grounded Multi-Agent Test Oracle Synthesis30 Oct 2025
Similar, not cited
Close in wording, no citation either way
- 2025AugmenTest: Enhancing Tests with LLM-Driven Oracles
- 2026Multi-Agent LLM Collaboration for Unit Test Generation via Human-Testing-Inspired Workflows
- 2024The Potential of LLMs in Automating Software Testing: From Generation to Reporting
- 2025Rethinking Testing for LLM Applications: Characteristics, Challenges, and a Lightweight Interaction Protocol
- 2025Challenges in Testing Large Language Model Based Software: A Faceted Taxonomy
- 2024Large-scale, Independent and Comprehensive study of the power of LLMs for test case generation
- 2023Towards Autonomous Testing Agents via Conversational Large Language Models
- 2026Agent-Based Test Assertion Generation via Diverse Perspective Aggregation