Developer tools · Research feature

Study benchmarks LLMs in generating unit tests across five underused programming languages

A new benchmark evaluates how well large language models generate unit tests in real-world repository settings across Rust, Go, Julia, PHP, and Ruby.

Adapted from research by Dung Le Quang, Dong Cao Van, Nam Le Hai and colleagues.

arXiv preprint revision · 2026-09-15 · Attribution & reuse
In this article
Editorial illustration of stacked plates.

Editor’s introduction

It measures test pass rates, coverage, and a new metric, Invocation Rate (IR), to determine if generated tests meaningfully exercise code functionality. The research compares performance across 14 state-of-the-art LLMs under realistic conditions, including containerized execution and varied context augmentation methods. The evaluation includes both standard and agentic workflows, with a stratified subset of functions to balance ease and difficulty. Findings are limited to the specific languages and repository settings included in the benchmark, and do not generalize to all software ecosystems or development practices.

Introduction

Writing unit tests is a time-consuming yet critical part of software development; studies estimate it can take around 15% of a developer’s time. This has motivated decades of research into automated unit test generation. Traditional approaches (e.g., search-based, symbolic, or random test generation) can produce tests with reasonable coverage, but these auto-generated tests often suffer from poor readability and trivial or ineffective assertions. Recently, large language models (LLMs) have emerged as a promising alternative, significantly accelerating unit test generation and often producing more natural, human-like test cases. Although LLMs have been widely adopted for unit test generation, their evaluation still faces significant challenges in practical applicability and multilingual adaptability. Existing test generation benchmarks often fail to reflect realistic repository-level constraints and remain biased toward a small set of programming languages, limiting our understanding of how LLMs perform in domain-specific and language-diverse software systems.

Second, although some recent frameworks and benchmarks consider repository-level test generation scenarios, they remain disproportionately centered on Java and Python. This narrow language focus limits the evaluation of LLM-based test generation methods across diverse programming ecosystems, hindering the development and assessment of tools that are generalizable and practically useful in multilingual software environments. Meanwhile, different programming languages exhibit distinct characteristics and domain-specific usage patterns. For instance, Rust has rapidly become a standard choice for memory-safe systems programming; Go underpins much of cloud-native infrastructure; Julia is driving advances in high-performance scientific computing; and PHP and Ruby continue to power a substantial portion of production web applications. These languages also introduce unique technical challenges; such as Rust’s ownership and borrowing model, that can invalidate generation strategies effective in more conventional language settings.

Automated unit test generation has a long history, spanning traditional search-based and heuristic techniques as well as more recent LLM-driven approaches. Classic generators can achieve reasonable coverage, but they often produce brittle, low-readability tests with trivial or uninformative assertions, limiting adoption in practice. In contrast, LLM-based systems can generate more natural test scaffolding and assertions, further incorporate execution-in-the-loop repair or analysis-guided prompting to improve validity.

From an evaluation perspective, several high-quality benchmarks for unit test generation have incorporated repository context, such as Defects4J, Methods2Test, and TestGenEval, but they remain largely centered on high-resource languages like Java and Python, limiting their applicability to other ecosystems. More recently, UniTSyn introduced a multilingual test generation framework; however, its evaluation is adapted from standalone code generation benchmarks such as HumanEval-X and McEval, which abstract away repository-level constraints and thus provide limited insight into the practical effectiveness of test generation methods in real-world settings.

Gap for Multilingual Repository-level Evaluation

Despite the widespread use of many programming languages in practice, benchmarks for evaluating unit test generation at the repository level remain scarce outside a few high-resource ecosystems. A key barrier lies in constructing reliable execution environments, which requires language-specific knowledge of build systems, testing frameworks, and dependency configurations. To address this gap, we present a large-scale multilingual, repository-level benchmark and data pipeline for test generation, enabling systematic and executable evaluation of test generation models across diverse programming languages.

Methodology

In this section, we describe the construction of XRepoTest and its context-aware evaluation framework, followed by an overview of the dataset’s scale, language coverage, and domain distribution. XRepoTest is repository-level rather than standalone: each task targets a focal function, but generated tests are inserted into and validated within the original project environment. These details highlight the design choices that make XRepoTest a robust benchmark for evaluating LLM-based unit test generation.

Repository Selection

For each language, to ensure quality and relevance, we apply filtering criteria including: a minimum of 500 GitHub stars, a clearly defined project structure with build configuration files (e.g., Cargo.toml, Project.toml, go.mod, composer.json, or Gemfile) to minimize human intervention in environment setup. Additionally, for each language, we ensure that selected repositories span at least two distinct application domains to promote diversity in the dataset. Following this process, we select 6–10 repositories per language, which together form the foundation of our benchmark dataset (See additional per-repository statistics in Appendix A.1, Table A.1).

Focal Method Extraction

From collected repositories, we use tree-sitter to parse source files into abstract syntax trees (ASTs), enabling language-agnostic traversal and structural analysis. From each AST, we extract top-level function and method definitions. To ensure functions’ quality and validity, we apply systematic filtering rules that enforce: (i) minimum code length, (ii) presence of observable outputs (explicit return statements), (iii) exclusion of existing test code, and (iv) syntactic validity. These criteria help eliminate trivial or degenerate functions while retaining semantically meaningful focal methods suitable for unit test generation. Complete filtering rules are detailed in Table A.2 in the Appendix.

Context Augmentation

To enable realistic and flexible repository-level test generation, our framework supports both static and dynamic context augmentation. The released XRepoTest benchmark provides precise, lightweight static context with File-level context (i.e. file content containing focal method) and LSP-based context that resolves argument definitions, type declarations, and relevant callee signatures via Language Server Protocol (LSP), inspired by recent studies. In addition, following repository-level code generation practices, XRepoTest supports optional Retrieval-based augmentation, in which sparse (BM25) or dense (UniXCoder - ) retrievers dynamically select relevant code snippets (i.e., code chunks) from the repository to enrich the prompt.

Standard Metrics

To evaluate the effectiveness of generated unit tests, we adopt a set of metrics commonly used in prior work on automated test generation. Test Pass Rate (TPR) measures runtime correctness as the fraction of compiled tests that execute without exceptions or assertion failures. To assess semantic coverage, we report Line Coverage (Cov), which measures the percentage of lines in the focal method exercised by the generated tests. We additionally compute Compilation Success Rate (CSR) and Mutation Score; we report a summary of both in §5.1 and present the full per-model values in Appendix Tables A.4 and A.5. Full metric definitions are provided in Appendix D.

Performance across LLMs on XRepoTest

In this experiment, we evaluate 14 state-of-the-art LLMs across model families and scales on XRepoTest using minimal focal/standard context (the focal method and class signature), following prior studies. We first summarize cross-model trends and then analyze results across individual languages. All languages in XRepoTest are evaluated under a unified protocol using greedy decoding. Details of the models and prompting templates are provided in Appendices A.11 and K.

Language-specific performance and challenges

Rust. Results highlight a scaffolding bottleneck: models frequently fail to assemble correct imports/crates and satisfy strict type and ownership constraints. Even strong systems often reach the focal method but do not reliably produce behavior-checking tests. Under the standard setting, Claude 4.5 Sonnet achieves the best Rust performance (TPR 12.78%, Cov 11.56%, IR 75.94%), while GPT-5.2 reaches TPR 12.24% and Cov 9.31%.

Ruby. Results are notably split: GPT-5.2 leads on TPR (25.78%) but achieves only 7.80% Cov, while Claude 4.5 Sonnet leads on Cov (14.25%) with a much lower TPR (6.37%). This TPR–Cov divergence suggests models can exercise code paths without producing passing assertions, reflecting the difficulty of Ruby’s DSL-heavy testing conventions.

Agentic and Iterative-Repair Evaluation

To go beyond single-turn prompting, we additionally evaluate agentic and execution-in-the-loop repair workflows under the same protocol (TPR, Cov, IR). Given the higher cost of agentic evaluation, we use a stratified subset sampling up to five easy and five hard focal functions per repository.

IR vs. TPR disagreement. Across the full benchmark, 9.7% of TPR-passing suites nonetheless fail IR (28.3% Rust, 19.2% Ruby, 0.6–0.7% Go/PHP, 6.1% Julia); manual inspection confirms these suites invoke mocked/stubbed or unrelated public APIs rather than the focal method, direct evidence IR captures failures TPR misses. Full per-language results, the repair table, and a Julia dispatch-mismatch case study are in Appendix F.

Conclusion

In this work, we introduced XRepoTest, a multilingual repository-level benchmark and evaluation framework for unit test generation that emphasizes realistic development settings, controlled context augmentation, and execution-based metrics. Covering multiple programming languages, diverse domains, and containerized environments, XRepoTest enables systematic analysis of how modern LLMs generate, invoke, and validate tests under different languages. Our evaluation of 14 state-of-the-art LLMs reveals substantial challenges stemming from language-specific constraints, domain complexity, and semantic issues in generated tests. To better assess behavioral validity, we proposed the novel Invocation Rate (IR) metric, complementing standard metrics like test pass rate (TPR) and coverage. We further explored the impact of context augmentation strategies on test generation. While static file-level context provides the most reliable gains across several languages, whereas more sophisticated augmentations such as LSP- or retrieval-based context yield selective and language-dependent benefits. Together, these findings position XRepoTest as a challenging and informative benchmark for advancing scalable and robust multilingual unit test generation in realistic repository contexts, while highlighting promising directions for future work in adaptive context selection, language-aware augmentation, and stronger semantic reasoning for test oracle construction.

Limitations

In this work, for comparability, we evaluate all models using a standardized prompt format and fixed decoding configuration. Alternative prompting strategies, decoding schemes, or tool-augmented settings may yield different absolute performance and could better exploit specific models. Similarly, retrieval-based augmentation is sensitive to retriever design choices (e.g., chunking strategy, indexing granularity, and relevance scoring), and our retrieval-based context results do not necessarily reflect an optimally tuned retrieval pipeline. Additionally, XRepoTest focuses on five underexplored yet impactful languages (Rust, Go, Julia, PHP, and Ruby) and a curated set of real-world repositories. While this scope enables meaningful multilingual, repository-level evaluation, the results may not directly generalize to other programming languages, application domains, or testing frameworks. To partially address this, we release an extensible, containerized evaluation pipeline designed to facilitate future expansion to additional languages, repositories, and test ecosystems.

Containerized provisioning and execution

After integrating the generated tests, we execute an automated evaluation pipeline. First, the project is compiled to detect syntactic errors and unresolved dependencies. If compilation succeeds, the test suite is executed and code coverage is measured using language-specific tooling. The entire evaluation process is containerized with Docker to ensure reproducibility and consistency across environments. To support future research on LLM-based test generation, we release our evaluation framework publicly.

Full Results of LLMs Performance

This section presents the complete set of experimental results for all models. Table A.4 summarizes the evaluation metrics, including test pass rate (TPR), line coverage (Cov), and invocation rate (IR). CSR values are omitted from this table and available upon request. Together, these metrics offer a comprehensive assessment of model performance, capturing both the syntactic correctness and the semantic quality of the generated tests across different programming languages.

Domain-Based Performance Analysis

To understand how model performance varies across different application domains, we analyze test pass rates across repository categories. We categorize each benchmark repository into one of six domains: Scientific Computing, Data Structure & Algorithm, Developer Tool, Web/Framework, Testing & Mocking, and Utilities. Figure A.1 presents a comprehensive comparison using spider charts. The left subplot shows ten models in standard mode (baseline setting without context enrichment), while the right subplot compares three representative models (GPT-5.2, Claude 4.5 Sonnet, and GPT-OSS 120B) in file context mode. Each axis represents a unique (language, domain) pair, and the radial distance indicates the test pass rate achieved by each model.

The visualization reveals several key insights. First, performance exhibits significant variation across domains even within the same language, suggesting that domain-specific characteristics (e.g., mathematical abstractions in scientific computing vs. string manipulation in utilities) present distinct challenges for test generation. Second, models show different strengths across domains: while proprietary frontier models (GPT-5.2, Claude 4.5 Sonnet) generally achieve higher test pass rates, open-source and smaller models demonstrate competitive performance in certain language-domain combinations. Comparing standard mode with file context mode reveals that contextual enrichment can significantly improve performance, particularly for domains requiring understanding of complex type relationships or API usage patterns.

Mutation Results

Mutation testing meaningfully differentiates model capabilities beyond pass rate. GPT-5.2 achieves the highest MS across all three languages (Go: 19.62%, Rust: 4.14%, Ruby: 6.29%), while Claude 4.5 Sonnet ranks second in Go MS (18.87%). Smaller models often exhibit low MS despite moderate pass rates, confirming that passing repository tests does not necessarily imply strong fault-detection capability.

MS@Pass scores are consistently higher than MS across all models and languages, showing that test oracles are effective when tests execute successfully, which is the primary bottleneck is test executability rather than assertion quality. The ranking patterns remain broadly consistent with our overall evaluation: stronger repository-level models also tend to achieve higher MS, reinforcing the benchmark’s internal validity.

Correlation with SWE-bench

To connect unit test generation and broader software engineering capability, we analyze correlations between model performance on XRepoTest and their SWE-bench Verified scores. SWE-bench has emerged as a widely used yardstick for evaluating LLMs on realistic software engineering tasks, where a model must produce code changes that resolve real repository issues under test-based verification. We use it here as an external proxy for general software engineering capability.

Benchmark Hardness Analysis

To understand whether different models solve the same set of problems or exhibit unique strengths, we conduct a benchmark hardness analysis focusing on three representative flagship models: Claude Sonnet 4.5, GPT-OSS-120B, and GPT-5.2. We consider a sample as successfully solved if the generated test passes and achieves non-zero line coverage. This criterion ensures that the test not only compiles and executes without errors but also exercises the focal function meaningfully.

This hardness analysis provides empirical evidence that benchmark difficulty is not uniform across models, different models exhibit complementary strengths, and a significant portion of the benchmark remains challenging for all evaluated systems, preserving discriminative power for future model development.

Agentic setup

We evaluate a headless Claude Code agent with full repository access, including repository navigation, source inspection, compilation, execution, and iterative repair. Due to the substantially higher computational cost of agentic evaluation, we construct a stratified subset by sampling up to five easy and five hard focal functions from each repository (based on Claude 4.5 Sonnet’s results). The agent is compared against the same underlying model under the standard single-turn protocol (TPR, Cov, IR). Table A.6 reports the complete per-language results.

IR vs. TPR disagreement

Across the full benchmark, we measure the fraction of TPR-passing suites that fail IR: 9.7% overall, rising to 28.3% for Rust and 19.2% for Ruby, but only 0.6–0.7% for Go and PHP (Julia: 6.1%). Manual inspection shows these suites typically invoke mocked or stubbed code, or unrelated public APIs, rather than the focal function—direct evidence that IR captures failures TPR misses.

Julia dispatch-mismatch case study

At first glance this appears correct: it compiles, passes, and even calls Base.iterate, suggesting the target has been exercised. However, because the argument is a plain Deque rather than Iterators.Reverse{<:Deque}, Julia’s multiple dispatch resolves to the forward-iteration overload, never the focal method, resulting in 0/13 covered lines (0% Cov) despite a successful test execution. A pass-rate metric alone would regard this as success, while coverage reveals the target was never exercised. Across the Julia agentic subset we observe this dispatch-mismatch pattern for 16 focal functions, including 7 with zero line coverage, demonstrating that even modern agentic systems can generate superficially correct tests that fail to validate the intended implementation.

Test Design & Mocking

Failures from missing fixtures, incorrect mocking, or improper test setup, reflecting the complexity of framework conventions and dependency injection patterns. The primary indicator is tests that pass all checks but achieve zero focal coverage (covered_lines == 0), suggesting the focal function was never invoked. Examples include mocking the class under test instead of external dependencies, hardcoded database IDs without data setup, and global state pollution without cleanup.