CITYWALK : Enhancing LLM-Based C++ Unit Test Generation via Project-Dependency Awareness and Language-Specific Knowledge
Top Cited Papers
Open Access
- 24 April 2026
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Software Engineering and Methodology
- Vol. 35 (5) , 1-32
Abstract
Unit testing plays a pivotal role in the software development lifecycle, as it ensures code quality. However, writing high-quality unit tests remains a time-consuming task for developers in practice. More recently, the application of large language models (LLMs) in automated unit test generation has demonstrated promising results. Existing approaches primarily focus on interpreted programming languages (e.g., Java), while mature solutions tailored to compiled programming languages like C++ are yet to be explored. The intricate language features of C++, such as pointers, templates, and virtual functions, pose particular challenges for LLMs in generating both executable and high-coverage unit tests. To tackle the aforementioned problems, this article introduces CITYWALK , a novel LLM-based framework for C++ unit test generation. CITYWALK enhances LLMs by providing a comprehensive understanding of the dependency relationships within the project under test via program analysis. Furthermore, CITYWALK incorporates language-specific knowledge about C++ derived from project documentation and empirical observations, significantly improving the correctness of the LLM-generated unit tests. We implement CITYWALK by employing the widely popular LLM GPT-4o. The experimental results show that CITYWALK outperforms current state-of-the-art approaches on a collection of ten popular C++ projects. Our findings demonstrate the effectiveness of CITYWALK in generating high-quality C++ unit tests.Keywords
All Related Versions
Funding Information
- National Key Research and Development Program of China (2024YFB4505902)
- Major Project of ISCAS (ISCAS-ZD-202302)
- Basic Research Project of ISCAS (ISCAS-JCZD-202403)
- Youth Innovation Promotion Association of the Chinese Academy of Sciences (Y2022044 and 2023121)
This publication has 52 references indexed in Scilit:
- Reinforcement Learning from Automatic Feedback for High-Quality Unit Test Generation2025
- SAGA: Summarization-Guided Assert Statement GenerationJournal of Computer Science and Technology, 2025
- A3Test: Assertion-Augmented Automated Test case generationInformation and Software Technology, 2024
- Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproduction2023
- CITRUS: Automated Unit Testing Tool for Real-world C++ Programs2022
- Mock objects for testing java systemsEmpirical Software Engineering, 2018
- Do Automatically Generated Unit Tests Find Real Faults? An Empirical Study of Effectiveness and Challenges (T)2015
- A survey of software testing practices in CanadaJournal of Systems and Software, 2013
- Feedback-Directed Random Test Generation29th International Conference on Software Engineering (ICSE'07), 2007
- Augmenting Automatically Generated Unit-Test Suites with Regression Oracle Checking2006