Clarifying Semantics of In-Context Examples for Unit Test Generation
Not on the map. Why?
Abstract (arXiv)
Recent advances in large language models (LLMs) have enabled promising performance in unit test generation through in-context learning (ICL). However, the quality of in-context examples significantly influences the effectiveness of generated tests-poorly structured or semantically unclear test examples often lead to suboptimal outputs. In this paper, we propose CLAST, a novel technique that systematically refines unit tests to improve their semantic clarity, thereby enhancing their utility as in-context examples. The approach decomposes complex tests into logically clearer ones and improves semantic clarity through a combination of program analysis and LLM-based rewriting. We evaluated CLAST on four open-source and three industrial projects. The results demonstrate that CLAST largely outperforms UTgen, the state-of-the-art refinement technique, in both preserving test effectiveness and enhancing semantic clarity. Specifically, CLAST fully retains the original effectiveness of unit tests, while UTgen reduces compilation success rate (CSR), pass rate (PR), test coverage (Cov), and mutation score (MS) by an average of 12.90%, 35.82%, 4.65%, and 5.07%, respectively. Over 85.33% of participants in our user study preferred the semantic clarity of CLAST-refined tests. Notably, incorporating CLAST-refined tests as examples effectively improves ICL-based unit test generation approaches such as RAGGen and TELPA, resulting in an average increase of 25.97% in CSR, 28.22% in PR, and 45.99% in Cov for generated tests, compared to incorporating UTgen-refined tests. The insights from the follow-up user study not only reinforce CLAST's potential impact in software testing practice but also illuminate avenues for future research.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 20 of its 46 references that are in the map. First posted on arXiv 2 Oct 2025.
Builds on
20 of 46 references.
References · 20
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
- 2023No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generationcited by 82
- 2024Code-Aware Prompting: A study of Coverage Guided Test Generation in Regression Setting using LLMcited by 63
- 2022Pynguin: Automated Unit Test Generation for Pythoncited by 49
- 2024HITS: High-coverage LLM-based Unit Test Generation via Method Slicingcited by 37
- 2023A3Test: Assertion-Augmented Automated Test Case Generationcited by 33
- 2024On the Evaluation of Large Language Models in Unit Test Generationcited by 33
- 2022Toward Understanding Deep Learning Framework Bugscited by 26
8 more
- 2024CoderUJB: An Executable and Unified Java Benchmark for Practical Programming Scenarioscited by 11
- 2024Leveraging Large Language Models for Enhancing the Understandability of Generated Unit Testscited by 11
- 2024Advancing Code Coverage: Incorporating Program Analysis with Large Language Modelscited by 8
- 2024Evaluating Large Language Models in Detecting Test Smellscited by 6
- 2024CSA-Trans: Code Structure Aware Transformer for ASTcited by 3
- 2014Test Case Purification for Improving Fault Localizationcited by 2
- 2024Dependency-Aware Code Naturalnesscited by 2
- 2025Reflective Unit Test Generation for Precise Type Error Detection with Large Language Modelscited by 2
Built on by
Citing papers per year: 2025: 1; 2026: 2.
3 papers.