Unify and Triumph: Polyglot, Diverse, and Self-Consistent Generation of Unit Tests with LLMs
Not on the map. Why?
Abstract (arXiv)
Large language model (LLM)-based test generation has gained attention in software engineering, yet most studies evaluate LLMs' ability to generate unit tests in a single attempt for a given language, missing the opportunity to leverage LLM diversity for more robust testing. This paper introduces PolyTest, a novel approach that enhances test generation by exploiting polyglot and temperature-controlled diversity. PolyTest systematically leverages these properties in two complementary ways: (1) Cross-lingual test generation, where tests are generated in multiple languages at zero temperature and then unified; (2) Diverse test sampling, where multiple test sets are generated within the same language at a higher temperature before unification. A key insight is that LLMs can generate diverse yet contradicting tests -- same input, different expected outputs -- across languages and generations. PolyTest mitigates inconsistencies by unifying test sets, fostering self-consistency and improving overall test quality. Unlike single-language or single-attempt approaches, PolyTest enhances testing without requiring on-the-fly execution, making it particularly beneficial for weaker-performing languages. We evaluate PolyTest on Llama3-70B, GPT-4o, and GPT-3.5 using EvalPlus, generating tests in five languages (Java, C, Python, JavaScript, and a CSV-based format) at temperature 0 and sampling multiple sets at temperature 1. We observe that LLMs frequently generate contradicting tests across settings, and that PolyTest significantly improves test quality across all considered metrics -- number of tests, passing rate, statement/branch coverage (up to +9.01%), and mutation score (up to +11.23%). Finally, PolyTest outperforms Pynguin in test generation, passing rate, and mutation score.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 23 of its 47 references that are in the map. First posted on arXiv 20 Mar 2025.
Builds on
23 of 47 references.
References · 23
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 2023Software Testing with Large Language Models: Survey, Landscape, and Visioncited by 163
- 2022Productivity Assessment of Neural Code Completioncited by 97
- 2023Evaluating the Code Quality of AI-Assisted Code Generation Tools: An Empirical Study on GitHub Copilot, Amazon CodeWhisperer, and ChatGPTcited by 71
- 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
- 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
- 2023Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Studycited by 44
- 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
11 more
- 2022Code Generation Tools (Almost) for Free? A Study of Few-Shot, Pre-Trained Language Models on Codecited by 39
- 2024Large Language Models as Test Case Generators: Performance Evaluation and Enhancementcited by 27
- 2023Multi-modal Latent Space Learning for Chain-of-Thought Reasoning in Language Modelscited by 24
- 2022Piloting Copilot, Codex, and StarCoder2: Hot Temperature, Cold Prompts, or Black Magic?cited by 14
- 2022Towards using Few-Shot Prompt Learning for Automating Model Completioncited by 13
- 2021An Empirical Study of Automated Unit Test Generation for Pythoncited by 10
- 2024TestSpark: IntelliJ IDEA's Ultimate Test Generation Companioncited by 9
- 2023On Codex Prompt Engineering for OCL Generation: An Empirical Studycited by 8
- 2023An empirical study of ChatGPT-3.5 on question answering and code maintenancecited by 4
- 2024Generative AI to Generate Test Data Generatorscited by 4
- 2021Comparing Mutation Coverage Against Branch Coverage in an Industrial Settingcited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025LLM4VV: Evaluating Cutting-Edge LLMs for Generation and Evaluation of Directive-Based Parallel Programming Model Compiler Tests ↗
- 2025Rethinking Testing for LLM Applications: Characteristics, Challenges, and a Lightweight Interaction Protocol
- 2026SWE-Mutation: Can LLMs Generate Reliable Test Suites in Software Engineering?
- 2026LLMs taking shortcuts in test generation: A study with SAP HANA and LevelDB
- 2024Large-scale, Independent and Comprehensive study of the power of LLMs for test case generation
- 2025Learning to Generate Unit Tests for Automated Debugging
- 2026TAM-Eval: Evaluating LLMs for Automated Unit Test Maintenance
- 2025Challenges in Testing Large Language Model Based Software: A Faceted Taxonomy