百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
XRepoTest

XRepoTest

> DevOps
免费

[EMNLP 2026] 一个多语言的仓库级单元测试生成基准,用于评估 LLM 的性能

163 stars0 点赞2 次浏览
GitHub

工具介绍

[EMNLP 2026] 一个多语言的仓库级单元测试生成基准,用于评估 LLM 的性能

Benchmarking Multilingual Repository-Level Unit Test Generation for Large Language Models


Overview

XRepoTest is a repository-level benchmark for evaluating how well large language models generate unit tests for real-world functions across 5 programming languages. It provides an end-to-end pipeline: repository crawling, prompt construction, LLM response generation, and Docker-based execution; that compiles, runs, and measures the coverage of every generated test against the actual source code.

Unlike single-language or synthetic benchmarks, XRepoTest evaluates repository-level test generation in the wild, letting you compare models, prompting strategies, and retrieval-augmented contexts under uniform, real execution conditions.


Highlights

  • 5 languages, one pipeline. Go, Rust, Julia, PHP, and Ruby evaluated with their native test frameworks (go test, cargo test, Test, PHPUnit, RSpec).
  • Real execution, not pattern-matching. Every test is compiled and run inside a language-specific Docker container; metrics come from actual compiler/test-runner/coverage-mutator outputs.
  • 4 research axes you can ablate. standard → lsp_context → file_context → rag_bm25 / rag_dense prompt modes.
  • Mutation testing (go, rust, ruby) to measure test quality, not just pass rate.
  • Iterative repair and agentic modes for studying self-repair and agent-driven test generation.
  • Post-run analysis suite data leakage, domain/error analysis, significance testing, overlap and correlation analysis.

Benchmark Overview

For each language, XRepoTest crawls public repositories to extract function-level records, enriches each function with contextual metadata (LSP argument/type info, focal methods, or retrieval contexts), and asks a model to write a unit test targeting that function. The generated test is then executed against the repository's real code.

Supported languages

Language Extension Test framework Mutation tool
Go .go go test go-mutesting ✅
Rust .rs cargo test cargo-mutants ✅
Julia .jl Test —
PHP .php PHPUnit —
Ruby .rb RSpec mutant ✅

Mutation testing is fully wired into the Docker evaluators for Go, Rust, and Ruby (the --enable_mutation flag affects only those three).

Reported metrics

Metric Meaning
compiled_rate % of generated tests that compile
invocation_rate % that actually invoke the focal function
test_pass_rate % that pass when run against real code
line_coverage macro-averaged line coverage across focal functions
mutation_score % of injected mutants killed (Go / Rust / Ruby)

️ Pipeline at a glance

Overview of the XRepoTest benchmark construction and context-aware evaluation workflow, covering repository selection, parsing, filtering, unit-test execution, and context-aware prompt construction.


Installation

bash
# Core dependencies + the `xrepotest` & `xrepotest-run` CLI commands
pip install -e .

# Extra LSP enrichment / RAG retrieval dependencies
pip install -e ".[lsp,rag]"

# Development tooling (pytest, ruff, mypy, black, ...)
pip install -e ".[dev]"

Prerequisites

  • Python ≥ 3.10
  • Docker — evaluation executes generated tests in the language-specific images (dungxg502/xrepotest-:latest). Docker must be running for xrepotest eval, and the images pulled before first use:
    bash
    # pull once, before evaluating
    docker pull dungxg502/xrepotest-go:latest        # + rust / julia / php / ruby

Benchmark data

The XRepoTest datasets are published to the HuggingFace Hub as a single dataset repo solis-soict/xrepotest and downloaded with the bundled fetch script. Run this once after cloning, it places each artifact where the pipeline expects it:

bash
pip install "huggingface_hub[cli]"
python scripts/fetch_data.py                       # fetch all groups (base, lsp, rag)

The fetch script downloads from one configurable repo (default solis-soict/xrepotest, or set XREPOTEST_HF_REPO=/xrepotest for a mirror):

Remote folder Local destination Modes it enables
data/base src/xrepotest/environments/xrepotest/ standard, file_context
data/lsp data/enriched/lsp/ lsp_context
data/rag data/enriched/rag/ rag_bm25, rag_dense

Example: fetch only the core benchmark, or only one language:

bash
python scripts/fetch_data.py --group base        # core task items only
python scripts/fetch_data.py --lang rust         # rust across all groups
python scripts/fetch_data.py --force             # re-download / overwrite

repo_data/ (the raw crawled source repositories) is not distributed here. It is only needed to rebuild the dataset or the evaluation Docker images from scratch, and is reproduced from the public source repos referenced in each record's metadata.

Dev container (optional, recommended for evaluation)

The repo ships a VS Code Dev Container (.devcontainer/) that sets up a Python 3.12 + docker-in-docker environment and checks that Docker is available on first start. This is the fastest way to get an evaluation-ready setup.

Usage (VS Code):

  1. Install the Dev Containers extension.

  2. With the repo open, run Ctrl+Shift+P → "Dev Containers: Reopen in Container".

  3. On first boot the container runs .devcontainer/setup.sh (editable install + git config) and you're ready to go. You can then pull the images explicitly:

    bash
    bash .devcontainer/pull_images.sh        # docker pull the 5 evaluation images

The devcontainer is intentionally evaluation-focused — it does not install the Go/Rust/Julia/PHP/Ruby toolchains, because evaluation runs inside the language containers. If you instead need to build the dataset (crawler + LSP enrichment + RAG indexing), install those toolchains separately:

bash
bash .devcontainer/install_languages.sh

Quickstart

Assuming you have installed and fetched the data, run the complete evaluation for one (language, mode, model) combination:

bash
xrepotest run \
  --lang go \
  --mode standard \
  --model gpt-4o \
  --api_base  \
  --api_key 

Everything is written under src/experiments/evaluation/data/, following the output path contracts below.

Step-by-step

Equivalent to xrepotest run, broken into stages for finer control:

…

Additional subcommands

  • Iterative repair pre-processing: xrepotest repair-preprocess reformats failing results before a repair attempt (see --help).
  • Agentic evaluation: xrepotest agentic runs agent-driven / Claude Code test generation over a task subset (see --help); it needs a task_subset_.json.

All subcommands expose --help; xrepotest --help lists the full surface.


️ Prompt Modes

Mode Context added to the prompt CLI value
Standard Focal function only standard
LSP context LSP-extracted argument types & focal methods lsp_context
File context Full surrounding source file file_context
BM25 retrieval BM25-retrieved context (ws_k) rag_bm25
Dense retrieval Dense/LM-retrieved context (ws_k) rag_dense

⚙️ Configuration

The API endpoint and key are configured in src/xrepotest/config.py (not read from environment variables):

  • API_BASE_URL - your OpenAI-compatible endpoint. There is no default baked in; set this to your provider before running responses / run (or pass --api_base to override it for a single run).
  • API_KEY_FILE - path to a plain-text file holding only the key (no quotes/newlines). The key itself lives outside the repo (/keys/ is gitignored) so the module stays committable.
python
# src/xrepotest/config.py
API_BASE_URL = "https://api.example.com/v1"   # fill in YOUR provider's endpoint
API_KEY_FILE = "/keys/api_key.key"           # file contains only the key

If you run responses / run without setting API_BASE_URL (or --api_base), the pipeline aborts with a clear message rather than silently targeting a default host.

Experiment-level LLM settings live in src/experiments/evaluation/llm/config.py.


️ Repository layout

…

Output path contracts

Data flows through JSONL (one valid JSON object per line) across the pipeline:

Artifact Path
Prompts data/responses///prompts.jsonl
Raw responses data/responses////prompts_responses.jsonl
Repair responses ...//repair/prompts_responses_attempt{N}.jsonl
Processed data/results////processed.jsonl
Processed (repair) .../processed_iterative_repair_attempt{N}.jsonl
Eval output summary.json + detailed_results.jsonl (same results dir)
Repair eval detailed_results_repair_attempt{N}.jsonl

(All under src/experiments/evaluation/data/.)


️ Development

bash
pytest          # run all tests
pytest -k pattern
pytest tests/test_cli.py -v

ruff check src  # lint
mypy src        # type check

Conventions

  • Language identifiers are lowercase: go, rust, julia, ruby, php.
  • Model folder names replace / and : with _ (e.g. gpt-4o, microsoft/phi_3).
  • Data format is JSONL throughout (one valid JSON object per line).
  • Paths should be resolved via src/xrepotest/paths.py helpers so they work from any cwd.

Citation

If you use XRepoTest in your research, please cite:

bibtex
@inproceedings{xrepotest2026,
  title     = {{XRepoTest}: Benchmarking Multilingual Repository-Level Unit Test Generation for Large Language Models},
  author    = {Le Quang, Dung and Cao Van, Dong and Le Hai, Nam and Ngo Van, Linh and Bui, Thi-Mai-Anh and Nguyen, Phuong T.},
  booktitle = {Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing (EMNLP)},
  year      = {2026},
  note      = {Main Conference}
}

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

llm-evaluationtest-automationunit-testing

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年9月9日
最后更新2026年9月18日
分类DevOps
定价免费

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理