Learning to Generate Unit Test via Adversarial Reinforcement Learning
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
Other references · 34
- 2022Training language models to follow instructions with human feedbackcited by 15,971
- 2017Proximal Policy Optimization Algorithmscited by 15,215
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 9,379
- 2025Qwen3 Technical Reportcited by 8,820
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
- 2024GPT-4o System Cardcited by 4,588
- 2025DAPO: An Open-Source LLM Reinforcement Learning System at Scalecited by 2,810
- 2020Learning to summarize from human feedbackcited by 2,588
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2024Tulu 3: Pushing Frontiers in Open Language Model Post-Trainingcited by 1,053
22 more
- 2017Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithmcited by 734
- 2024ORPO: Monolithic Preference Optimization without Reference Modelcited by 562
- 2024Self-Play Fine-Tuning Converts Weak Language Models to Strong Language Modelscited by 557
- 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 358
- 2025Absolute Zero: Reinforced Self-play Reasoning with Zero Datacited by 344
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
- 2023TACO: Topics in Algorithmic COde generation datasetcited by 160
- 2025STP: Self-play LLM Theorem Provers with Iterative Conjecturing and Provingcited by 79
- 2024Automated Unit Test Improvement using Large Language Models at Metacited by 75
- 2021Asymmetric self-play for automatic goal discovery in robotic manipulationcited by 72
- 2025Co-Evolving LLM Coder and Unit Tester via Reinforcement Learningcited by 56
- 2024TestGenEval: A Real World Unit Test Generation and Test Completion Benchmarkcited by 52
- 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
- 2025CodeContests+: High-Quality Test Case Generation for Competitive Programmingcited by 46
- 2024TESTEVAL: Benchmarking Large Language Models for Test Case Generationcited by 40
- 2024CoverUp: Effective High Coverage Test Generation for Pythoncited by 38
- 2025Learning to Solve and Verify: A Self-Play Framework for Code and Test Generationcited by 35
- 2023A3Test: Assertion-Augmented Automated Test Case Generationcited by 33
- 2025Dynamic Scaling of Unit Tests for Code Reward Modelingcited by 33
- 2025Mutation-Guided LLM-based Test Generation at Metacited by 25
- 2025Learning to Generate Unit Tests for Automated Debuggingcited by 17
- 2025CoCoEvo: Co-Evolution of Programs and Test Cases to Enhance Code Generationcited by 14
Built on by
Citing papers per year: 2025: 3; 2026: 8.
11 papers.
- 2025A Survey of Reinforcement Learning for Large Reasoning Modelscited by 180
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 15
- 2026V1: Unifying Generation and Self-Verification for Parallel Reasonerscited by 12
- 2026Scaling Coding Agents via Atomic Skillscited by 8
- 2026ExecCritic: Learn to Test, Test to Improve for Coding Agentscited by 3
- 2026RM -RF: Reward Model for Run-Free Unit Test Evaluationcited by 2
- 2026Oracle Gap and Signal Fidelity: A Fixed-Pool Diagnostic for Test-Time Collaborationcited by 2
- 2025CodeChemist: Test-Time Scaling for Low-Resource Code Generation via Functional Knowledge Transfercited by 1
- 2026Themis: Training Robust Multilingual Code Reward Models for Flexible Multi-Criteria Scoringcited by 1
- 2026Improving Proficiency and Efficiency of Android GUI Agents via Self-Generating Tool Actionscited by 1
- 2026Schedule-and-Calibrate: Utility-Guided Multi-Task Reinforcement Learning for Code LLMscited by 0
- 2026ExecCritic: Learn to Test, Test to Improve for Coding Agents8 Sep 2026
- 2026Improving Proficiency and Efficiency of Android GUI Agents via Self-Generating Tool Actions6 Sep 2026
- 2026Oracle Gap and Signal Fidelity: A Fixed-Pool Diagnostic for Test-Time Collaboration20 Jul 2026
- 2026Schedule-and-Calibrate: Utility-Guided Multi-Task Reinforcement Learning for Code LLMs7 May 2026
- 2026Themis: Training Robust Multilingual Code Reward Models for Flexible Multi-Criteria Scoring1 May 2026
- 2026Scaling Coding Agents via Atomic Skills6 Apr 2026
- 2026V1: Unifying Generation and Self-Verification for Parallel Reasoners4 Mar 2026
- 2026RM -RF: Reward Model for Run-Free Unit Test Evaluation19 Jan 2026
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025CodeChemist: Test-Time Scaling for Low-Resource Code Generation via Functional Knowledge Transfer1 Oct 2025
- 2025A Survey of Reinforcement Learning for Large Reasoning Models10 Sep 2025
Similar, not cited
Close in wording, no citation either way
- 2026Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMs
- 2026Code-A1: Adversarial Evolving of Code LLM and Test LLM via Reinforcement Learning
- 2024Reinforcement Learning from Automatic Feedback for High-Quality Unit Test Generation
- 2023Reinforcement Learning from Automatic Feedback for High-Quality Unit Test Generation
- 2026EvolveCoder: Evolving Test Cases via Adversarial Verification for Code Reinforcement Learning
- 2025Rethinking Verification for LLM Code Generation: From Generation to Testing
- 2025HarnessLLM: Automatic Testing Harness Generation via Reinforcement Learning
- 2025Teaching Language Models to Critique via Reinforcement Learning