arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2505.09027cs.SEcs.AI
收藏

测试即提示:面向大语言模型代码生成的测试驱动开发基准

Tests as Prompt: A Test-Driven-Development Benchmark for LLM Code Generation

ONEKQ Lab, USA(ONEKQ实验室)

Yi Cui

AI总结:

本文提出 WebApp1K 基准,以测试用例同时作为提示与验证,评估 19 个前沿 LLM 的 TDD 代码生成能力,并揭示长上下文指令丢失等瓶颈。

摘要:

我们提出了 WebApp1K,这是一个用于评估大语言模型(LLM)在测试驱动开发(TDD)任务中表现的新型基准;在该任务中,测试用例同时充当代码生成的提示和验证手段。与依赖自然语言提示的传统方法不同,我们的基准强调 LLM 直接从测试用例理解并实现功能的能力,反映了真实的软件开发实践。该基准包含覆盖 20 个应用领域的 1000 个多样化挑战,评估 LLM 在上下文长度和多功能复杂性约束下生成紧凑、可运行代码的能力。我们的发现表明,指令遵循和上下文内学习是 TDD 成功的关键能力,其重要性超过了一般编程能力或预训练知识。通过对 19 个前沿模型的全面评估,我们揭示了长提示中的指令丢失等性能瓶颈,并提供了涵盖多种根本原因的详细错误分析。本工作强调了面向 TDD 的专用基准的实用价值,并为推进 LLM 在严格、应用驱动的编码场景中的能力奠定了基础。

英文摘要:

We introduce WebApp1K, a novel benchmark for evaluating large language models (LLMs) in test-driven development (TDD) tasks, where test cases serve as both prompt and verification for code generation. Unlike traditional approaches relying on natural language prompts, our benchmark emphasizes the ability of LLMs to interpret and implement functionality directly from test cases, reflecting real-world software development practices. Comprising 1000 diverse challenges across 20 application domains, the benchmark evaluates LLMs on their ability to generate compact, functional code under the constraints of context length and multi-feature complexity. Our findings highlight instruction following and in-context learning as critical capabilities for TDD success, surpassing the importance of general coding proficiency or pretraining knowledge. Through comprehensive evaluation of 19 frontier models, we reveal performance bottlenecks, such as instruction loss in long prompts, and provide a detailed error analysis spanning multiple root causes. This work underscores the practical value of TDD-specific benchmarks and lays the foundation for advancing LLM capabilities in rigorous, application-driven coding scenarios.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑