mlsanityData to 14 Oct 2026

Learning to Generate Unit Test via Adversarial Reinforcement Learning

arXiv 2508.21107 ↗First posted 28 Aug 2025cs.SE cs.AIcited by 11

On the map: Deep reinforcement learning methods → RL training of language and agent models

Abstract (arXiv)

Unit testing is a core practice in programming, enabling systematic evaluation of programs produced by human developers or large language models (LLMs). Given the challenges in writing comprehensive unit tests, LLMs have been employed to automate test generation, yet methods for training LLMs to produce high-quality tests remain underexplored. In this work, we propose UTRL, a novel reinforcement learning framework that trains an LLM to generate high-quality unit tests given a programming instruction. Our key idea is to iteratively train two LLMs, the unit test generator and the code generator, in an adversarial manner via reinforcement learning. The unit test generator is trained to maximize a discrimination reward, which reflects its ability to produce tests that expose faults in the code generator's solutions, and the code generator is trained to maximize a code reward, which reflects its ability to produce solutions that pass the unit tests generated by the test generator. In our experiments, we demonstrate that unit tests generated by Qwen3-4B trained via UTRL show higher quality compared to unit tests generated by the same model trained via supervised fine-tuning on human-written ground-truth unit tests, yielding code evaluations that more closely align with those induced by the ground-truth tests. Moreover, Qwen3-4B trained with UTRL outperforms frontier models such as GPT-4.1 in generating high-quality unit tests, highlighting the effectiveness of UTRL in training LLMs for this task.

Key facts. Cited by 11 papers in the map (data through 14 Oct 2026). Placed in RL training of language and agent models, one of 15 directions in Deep reinforcement learning methods. Builds on 35 of its 40 references that are in the map. First posted on arXiv 28 Aug 2025.

Builds on

35 of 40 references.

Closest ancestors · 1

Same direction, newest first

  1. 2025SFT Memorizes, RL Generalizes: A Comparative Study of Foundation Model Post-training28 Jan

Other references · 34

  1. 2022Training language models to follow instructions with human feedbackcited by 15,971
  2. 2017Proximal Policy Optimization Algorithmscited by 15,215
  3. 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 9,379
  4. 2025Qwen3 Technical Reportcited by 8,820
  5. 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
  6. 2024GPT-4o System Cardcited by 4,588
  7. 2025DAPO: An Open-Source LLM Reinforcement Learning System at Scalecited by 2,810
  8. 2020Learning to summarize from human feedbackcited by 2,588
  9. 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
  10. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  11. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  12. 2024Tulu 3: Pushing Frontiers in Open Language Model Post-Trainingcited by 1,053
22 more
  1. 2017Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithmcited by 734
  2. 2024ORPO: Monolithic Preference Optimization without Reference Modelcited by 562
  3. 2024Self-Play Fine-Tuning Converts Weak Language Models to Strong Language Modelscited by 557
  4. 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 358
  5. 2025Absolute Zero: Reinforced Self-play Reasoning with Zero Datacited by 344
  6. 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
  7. 2023TACO: Topics in Algorithmic COde generation datasetcited by 160
  8. 2025STP: Self-play LLM Theorem Provers with Iterative Conjecturing and Provingcited by 79
  9. 2024Automated Unit Test Improvement using Large Language Models at Metacited by 75
  10. 2021Asymmetric self-play for automatic goal discovery in robotic manipulationcited by 72
  11. 2025Co-Evolving LLM Coder and Unit Tester via Reinforcement Learningcited by 56
  12. 2024TestGenEval: A Real World Unit Test Generation and Test Completion Benchmarkcited by 52
  13. 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
  14. 2025CodeContests+: High-Quality Test Case Generation for Competitive Programmingcited by 46
  15. 2024TESTEVAL: Benchmarking Large Language Models for Test Case Generationcited by 40
  16. 2024CoverUp: Effective High Coverage Test Generation for Pythoncited by 38
  17. 2025Learning to Solve and Verify: A Self-Play Framework for Code and Test Generationcited by 35
  18. 2023A3Test: Assertion-Augmented Automated Test Case Generationcited by 33
  19. 2025Dynamic Scaling of Unit Tests for Code Reward Modelingcited by 33
  20. 2025Mutation-Guided LLM-based Test Generation at Metacited by 25
  21. 2025Learning to Generate Unit Tests for Automated Debuggingcited by 17
  22. 2025CoCoEvo: Co-Evolution of Programs and Test Cases to Enhance Code Generationcited by 14

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 3; 2026: 8.

11 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMs
  2. 2026Code-A1: Adversarial Evolving of Code LLM and Test LLM via Reinforcement Learning
  3. 2024Reinforcement Learning from Automatic Feedback for High-Quality Unit Test Generation
  4. 2023Reinforcement Learning from Automatic Feedback for High-Quality Unit Test Generation
  5. 2026EvolveCoder: Evolving Test Cases via Adversarial Verification for Code Reinforcement Learning
  6. 2025Rethinking Verification for LLM Code Generation: From Generation to Testing
  7. 2025HarnessLLM: Automatic Testing Harness Generation via Reinforcement Learning
  8. 2025Teaching Language Models to Critique via Reinforcement Learning