ChatPaper.aiChatPaper

TENET: Sfruttare i Test Oltre la Validazione per la Generazione di Codice

TENET: Leveraging Tests Beyond Validation for Code Generation

September 29, 2025
Autori: Yiran Hu, Nan Jiang, Shanchao Liang, Yi Wu, Lin Tan
cs.AI

Abstract

Il Test-Driven Development (TDD) è una pratica ampiamente adottata nell'ingegneria del software che richiede agli sviluppatori di creare ed eseguire test parallelamente all'implementazione del codice, garantendo che il comportamento del software sia continuamente validato e affinato. Nell'era del "vibe coding", in cui gli sviluppatori delegano sempre più la scrittura del codice a modelli linguistici di grandi dimensioni (LLM) specificando intenzioni di alto livello, il TDD diventa ancora più cruciale, poiché i casi di test fungono da specifiche eseguibili che definiscono e verificano esplicitamente la funzionalità desiderata, andando oltre ciò che le descrizioni in linguaggio naturale e il contesto del codice possono trasmettere. Sebbene il "vibe coding" sotto TDD sia promettente, ci sono tre principali sfide: (1) selezionare una suite di test piccola ma efficace per migliorare l'accuratezza della generazione e controllare il carico di esecuzione, (2) recuperare contesti come il codice rilevante in modo efficiente, e (3) utilizzare sistematicamente il feedback dei test per un affinamento efficace del codice. Per affrontare queste sfide, introduciamo TENET, un agente LLM per la generazione di funzioni in repository complessi del mondo reale in un contesto TDD. TENET presenta tre componenti: (1) un meccanismo innovativo di test harness che seleziona una suite di test concisa per massimizzare la diversità degli scenari di utilizzo target; (2) un set di strumenti personalizzati per l'agente che esegue un recupero efficiente del codice rilevante con debug interattivo; e (3) un flusso di lavoro di affinamento basato sulla riflessione che analizza iterativamente i fallimenti, integra il contesto e applica il perfezionamento del codice. TENET raggiunge il 69,08% e l'81,77% di Pass@1 sui benchmark RepoCod e RepoEval, superando rispettivamente i migliori baseline agentici di 9,49 e 2,17 punti percentuali. Inoltre, questo è il primo studio sulla generazione di codice guidata da test con contesto a livello di repository, esaminando come diversi aspetti delle suite di test influenzino le prestazioni degli agenti LLM in un contesto TDD.
English
Test-Driven Development (TDD) is a widely adopted software engineering practice that requires developers to create and execute tests alongside code implementation, ensuring that software behavior is continuously validated and refined. In the era of vibe coding, where developers increasingly delegate code writing to large language models (LLMs) by specifying high-level intentions, TDD becomes even more crucial, as test cases serve as executable specifications that explicitly define and verify intended functionality beyond what natural-language descriptions and code context can convey. While vibe coding under TDD is promising, there are three main challenges: (1) selecting a small yet effective test suite to improve the generation accuracy and control the execution workload, (2) retrieving context such as relevant code effectively, and (3) systematically using test feedback for effective code refinement. To address these challenges, we introduce TENET, an LLM agent for generating functions in complex real-world repositories under the TDD setting. TENET features three components: (1) a novel test harness mechanism that selects a concise test suite to maximize diversity of target usage scenarios; (2) a tailored agent toolset that performs efficient retrieval of relevant code with interactive debugging; and (3) a reflection-based refinement workflow that iteratively analyzes failures, replenishes context, and applies code refinement. TENET achieves 69.08% and 81.77% Pass@1 on RepoCod and RepoEval benchmarks, outperforming the best agentic baselines by 9.49 and 2.17 percentage points, respectively. In addition, this is the first study of test-driven code generation with repository-level context, examining how different aspects of test suites affect the performance of LLM agents under the TDD setting.
PDF32September 30, 2025