Skip to main content
QUICK REVIEW

[Paper Review] Scaling Test-Driven Code Generation from Functions to Classes: An Empirical Study

Yunhao Liang, Ruixuan Ying|arXiv (Cornell University)|Feb 3, 2026
Software Engineering ResearchComputer Science0 citations
TL;DR

This study advances test-driven code generation from function-level tasks to class-level synthesis using a dependency-aware TDD framework, introducing ClassEval-TDD and showing substantial gains in class-level correctness across eight LLMs.

ABSTRACT

Test-driven development (TDD) has been adopted to improve Large Language Model (LLM)-based code generation by using tests as executable specifications. However, existing TDD-style code generation studies are largely limited to function-level tasks, leaving class-level synthesis where multiple methods interact through shared state and call dependencies underexplored. In this paper, we scale test-driven code generation from functions to classes via an iterative TDD framework. Our approach first analyzes intra-class method dependencies to derive a feasible generation schedule, and then incrementally implements each method under method-level public tests with reflection-style execution feedback and bounded repair iterations. To support test-driven generation and rigorous class-level evaluation, we construct ClassEval-TDD, a cleaned and standardized variant of ClassEval with consistent specifications, deterministic test environments, and complete method-level public tests. We conduct an empirical study across eight LLMs and compare against the strongest direct-generation baseline (the best of holistic, incremental, and compositional strategies). Our class-level TDD framework consistently improves class-level correctness by 12 to 26 absolute points and achieves up to 71% fully correct classes, while requiring only a small number of repairs on average. These results demonstrate that test-driven generation can effectively scale beyond isolated functions and substantially improve class-level code generation reliability. All code and data are available at https://anonymous.4open.science/r/ClassEval-TDD-C4C9/

Motivation & Objective

  • Motivate scaling TDD from function-level to class-level software where methods share state and dependencies.
  • Introduce dependency-aware scheduling to determine a feasible method generation order within a class.
  • Develop a reflective repair mechanism to fix TDD-generated methods within a bounded budget.
  • Create ClassEval-TDD as a cleaned, deterministic benchmark for reliable class-level TDD evaluation.
  • Empirically evaluate across multiple LLMs and compare with strong baselines to quantify gains and failure modes.

Proposed method

  • Analyze intra-class method dependencies to derive a generation schedule that respects prerequisite relationships.
  • Iteratively implement each method in schedule using method-level public tests as executable specifications.
  • Use a reflection-style repair loop to diagnose failures, propose minimal patches, and patch until tests pass within a repair budget.
  • Construct ClassEval-TDD by repairing and standardizing ClassEval to ensure corrected docstrings, aligned skeletons, deterministic tests, and method-level public tests.
  • Evaluate eight LLMs across Holistic, Incremental, and Compositional baselines, measuring class-level and function-level success, and dependency accuracy.

Experimental results

Research questions

  • RQ1RQ1: How does repairing and standardizing ClassEval into ClassEval-TDD affect baseline generation performance across strategies and models?
  • RQ2RQ2: How accurately can LLMs infer intra-class method dependencies and produce feasible generation schedules?
  • RQ3RQ3: How effective is the dependency-aware class-level TDD framework in improving class-level correctness and reducing repairs?

Key findings

  • ClassEval-TDD consistently improves class-level and function-level success across all models and strategies compared to ClassEval.
  • Incremental generation becomes substantially more competitive on ClassEval-TDD, often approaching or surpassing Holistic performance.
  • Dependency inference by LLMs shows high recall and strong F1, with occasional topological-order violations indicating scheduling as a distinct failure mode.
  • Most dependency errors are due to over-approximation (extra_deps) in No-deps methods or missing dependencies (missing_deps) in With-deps methods, highlighting different bottlenecks.
  • Topological order violations are concentrated on a small set of tasks where semantic priors conflict with actual dependencies.
  • Overall, the framework achieves up to 71% fully correct classes with bounded repair budgets (max 3 repairs per method).

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.