LSPRAG: 语言无关的实时单元测试生成中的LSP引导RAG
LSPRAG: LSP-Guided RAG for Language-Agnostic Real-Time Unit Test Generation
AI总结:
LSPRAG通过利用语言服务器协议实现实时语言无关单元测试生成,显著提高了测试覆盖率。
摘要:
自动化单元测试生成对于稳健的软件开发至关重要,但现有方法在跨多种编程语言泛化和实时开发中存在困难。虽然大型语言模型(LLMs)提供了一个有前途的解决方案,但其生成高覆盖率测试代码的能力取决于提示一个焦点方法的简洁上下文。当前的解决方案,如检索增强生成,要么依赖于不精确的相似性搜索,要么要求创建成本高昂、语言特定的静态分析流水线。为了解决这一差距,我们提出了LSPRAG,这是一个针对实时、语言无关单元测试生成的简洁上下文检索框架。LSPRAG利用现成的语言服务器协议(LSP)后端,实时为LLMs提供精确的符号定义和引用。通过重用成熟的LSP服务器,LSPRAG为LLM提供语言感知的上下文检索,仅需最小的每种语言工程努力。我们对涵盖Java、Go和Python的开源项目评估了LSPRAG。与基线的最佳性能相比,LSPRAG在Go中将行覆盖率提高了高达174.合作共赢Java 213.31%,Python 31.57%。
英文摘要:
Automated unit test generation is essential for robust software development, yet existing approaches struggle to generalize across multiple programming languages and operate within real-time development. While Large Language Models (LLMs) offer a promising solution, their ability to generate high coverage test code depends on prompting a concise context of the focal method. Current solutions, such as Retrieval-Augmented Generation, either rely on imprecise similarity-based searches or demand the creation of costly, language-specific static analysis pipelines. To address this gap, we present LSPRAG, a framework for concise-context retrieval tailored for real-time, language-agnostic unit test generation. LSPRAG leverages off-the-shelf Language Server Protocol (LSP) back-ends to supply LLMs with precise symbol definitions and references in real time. By reusing mature LSP servers, LSPRAG provides an LLM with language-aware context retrieval, requiring minimal per-language engineering effort. We evaluated LSPRAG on open-source projects spanning Java, Go, and Python. Compared to the best performance of baselines, LSPRAG increased line coverage by up to 174.55% for Golang, 213.31% for Java, and 31.57% for Python.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。