mlsanityData to 7 Oct 2026

Unify and Triumph: Polyglot, Diverse, and Self-Consistent Generation of Unit Tests with LLMs

arXiv 2503.16144 ↗First posted 20 Mar 2025cs.SE cs.AIcited by 0

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

  1. 2021Program Synthesis with Large Language Modelscited by 3,509
  2. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
  3. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  4. 2022CodeT: Code Generation with Generated Testscited by 369
  5. 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
  6. 2023Software Testing with Large Language Models: Survey, Landscape, and Visioncited by 163
  7. 2022Productivity Assessment of Neural Code Completioncited by 97
  8. 2023Evaluating the Code Quality of AI-Assisted Code Generation Tools: An Empirical Study on GitHub Copilot, Amazon CodeWhisperer, and ChatGPTcited by 71
  9. 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
  10. 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
  11. 2023Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Studycited by 44
  12. 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
11 more
  1. 2022Code Generation Tools (Almost) for Free? A Study of Few-Shot, Pre-Trained Language Models on Codecited by 39
  2. 2024Large Language Models as Test Case Generators: Performance Evaluation and Enhancementcited by 27
  3. 2023Multi-modal Latent Space Learning for Chain-of-Thought Reasoning in Language Modelscited by 24
  4. 2022Piloting Copilot, Codex, and StarCoder2: Hot Temperature, Cold Prompts, or Black Magic?cited by 14
  5. 2022Towards using Few-Shot Prompt Learning for Automating Model Completioncited by 13
  6. 2021An Empirical Study of Automated Unit Test Generation for Pythoncited by 10
  7. 2024TestSpark: IntelliJ IDEA's Ultimate Test Generation Companioncited by 9
  8. 2023On Codex Prompt Engineering for OCL Generation: An Empirical Studycited by 8
  9. 2023An empirical study of ChatGPT-3.5 on question answering and code maintenancecited by 4
  10. 2024Generative AI to Generate Test Data Generatorscited by 4
  11. 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

  1. 2025LLM4VV: Evaluating Cutting-Edge LLMs for Generation and Evaluation of Directive-Based Parallel Programming Model Compiler Tests ↗
  2. 2025Rethinking Testing for LLM Applications: Characteristics, Challenges, and a Lightweight Interaction Protocol
  3. 2026SWE-Mutation: Can LLMs Generate Reliable Test Suites in Software Engineering?
  4. 2026LLMs taking shortcuts in test generation: A study with SAP HANA and LevelDB
  5. 2024Large-scale, Independent and Comprehensive study of the power of LLMs for test case generation
  6. 2025Learning to Generate Unit Tests for Automated Debugging
  7. 2026TAM-Eval: Evaluating LLMs for Automated Unit Test Maintenance
  8. 2025Challenges in Testing Large Language Model Based Software: A Faceted Taxonomy