SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.04531 · 2024

TESTEVAL: Benchmarking Large Language Models for Test Case Generation

arXiv · PDF · Open in the Atlas

Code that ran

10 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 2 violated it and 0 have no contract verdict; 8 failures of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2406.04531.json · badge: /api/ran/2406.04531.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
llm4softwaretesting/testeval canonical (classifier label)
classifier basis: census
10 ran · 5 no recorded run
FunctionStatusWhere it lives
add_lineno Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/data_utils.py
code served (permissive licence) · get_code("f4e5ad618a9a9cbb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

def add_lineno(code):
    """Add line numbers to code."""
    lines = code.split('\n')
    new_code = ''
    for i, line in enumerate(lines):
        new_code += f'{i + 1}. {line}\n'
    return new_code

# Simple string code to pass to the function
test_code = """def hello():
    print('world')
    return 42"""

ARGS = {
    'code': test_code
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
add_lineno_comment Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/data_utils.py
code served (permissive licence) · get_code("65d02e229f9a78b7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Analyze the function signature and body
# The function takes:
# 1. code (str) - a string containing code lines
# 2. docstring_lines (optional tuple/list) - line numbers marking docstring start and end

# The function:
# - Splits code by '\n'
# - Removes trailing empty lines
# - Adds line number comments to each line
# - If docstring_lines is provided, skips adding comments to lines within that range

# Setup valid arguments
code_sample = """def hello():
    print('world')
    return 42"""

docstring_lines_sample = (0, 1)

ARGS = {
    'code': code_sample,
    'docstring_lines': docstring_lines_sample
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
change_function_name Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/format.py
code served (permissive licence) · get_code("337d5c7705c284c3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import ast

ARGS = {
    "code": """def hello_world():
    print("Hello, World!")
    return 42""",
    "new_name": "goodbye_world"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
execute Ran
ran, violated the contract we drafted
llm4softwaretesting/testeval/eval_base.py
code served (permissive licence) · get_code("8671b30e9a445afa")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import signal

class TimeoutHandler:

    def __init__(self, timeout, error_message=None):
        self.timeout = timeout
        self.error_message = error_message

    def __enter__(self):
        signal.signal(signal.SIGALRM, self.raise_timeout)
        signal.alarm(self.timeout)

    def __exit__(self, type, value, traceback):
        signal.alarm(0)

    def raise_timeout(self, *args):
        raise TimeoutError(self.error_message)

def execute(test_code, timeout=5):
    """try to execute test code"""
    try:
        exec_globals = {}
        with TimeoutHandler(timeout):
            exec(test_code, globals())
            return True
    except AssertionError:
        return True
    except TimeoutError:
        return False
    except Exception as e:
        return (type(e).__name__, e)

# Setup code for ARGS
torch.manual_seed(0)

# Simple test code that should execute successfully
simple_test_code = """
x = 1 + 1
assert x == 2
"""

# Test code that raises AssertionError
assertion_test_code = """
assert False
"""

# Test code that runs quickly
quick_test_code = """
y = [1, 2, 3]
z = sum(y)
"""

ARGS = {
    "test_code": simple_test_code,
    "timeout": 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
execute Ran
ran, violated the contract we drafted
llm4softwaretesting/testeval/eval_branchcov.py
code served (permissive licence) · get_code("d95b2ac22f4237ce")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import signal

class TimeoutHandler:

    def __init__(self, timeout, error_message=None):
        self.timeout = timeout
        self.error_message = error_message

    def __enter__(self):
        signal.signal(signal.SIGALRM, self.raise_timeout)
        signal.alarm(self.timeout)

    def __exit__(self, type, value, traceback):
        signal.alarm(0)

    def raise_timeout(self, *args):
        raise TimeoutError(self.error_message)

def execute(test_code, timeout=5):
    """try to execute test code"""
    try:
        exec_globals = {}
        with TimeoutHandler(timeout):
            exec(test_code, globals())
            return True
    except AssertionError:
        return 'assertion error'
    except TimeoutError:
        return False
    except Exception as e:
        return (type(e).__name__, e)


# Setup code to construct valid arguments for execute()
test_code_simple = "assert 1 + 1 == 2"
test_code_assertion_fail = "assert 1 + 1 == 3"
test_code_with_torch = "import torch; x = torch.tensor([1.0, 2.0]); assert x.shape[0] == 2"

ARGS = {
    "test_code": test_code_simple,
    "timeout": 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_completion Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/gen_linecov_cot_hf.py
code served (permissive licence) · get_code("092972ae0ca5e520")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class MockTokenizer:
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=True):
        # Simulate converting messages to a prompt string
        prompt = ""
        for msg in messages:
            prompt += f"{msg['role']}: {msg['content']}\n"
        if add_generation_prompt:
            prompt += "assistant: "
        return prompt

class MockGenerator:
    def __init__(self):
        self.tokenizer = MockTokenizer()
    
    def __call__(self, prompt, max_new_tokens=100, temperature=0.7, return_full_text=False):
        # Simulate text generation
        generated_text = "This is a generated completion."
        return [{'generated_text': generated_text}]

class MockArgs:
    def __init__(self, model, max_tokens, temperature):
        self.model = model
        self.max_tokens = max_tokens
        self.temperature = temperature

args = MockArgs(
    model='mistralai/Mistral-7B-Instruct-v0.3',
    max_tokens=100,
    temperature=0.7
)

generator = MockGenerator()

prompt = "What is the capital of France?"

system_message = "You are a helpful assistant."

ARGS = {
    'args': args,
    'generator': generator,
    'prompt': prompt,
    'system_message': system_message
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
match_path Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
llm4softwaretesting/testeval/eval_pathcov.py
code served (permissive licence) · get_code("2d783fc0a836c6b1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Analyze the function:
# - generated_path: used with len() and indexed with [i-1], so it's a sequence
# - ref_path: used with len() and indexed with [j-1], so it's a sequence
# - Both are compared for equality with ==
# - The function computes longest common subsequence similarity

# Create two simple paths as lists of comparable elements
generated_path = [1, 2, 3, 4, 2]
ref_path = [1, 2, 5, 4]

ARGS = {
    "generated_path": generated_path,
    "ref_path": ref_path,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_jsonl Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/data_utils.py
code served (permissive licence) · get_code("60c584f55c9451fc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSONL file with test data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")

# Write some test JSONL data
with open(temp_file, 'w') as f:
    f.write(json.dumps({"id": 1, "text": "hello"}) + "\n")
    f.write(json.dumps({"id": 2, "text": "world"}) + "\n")
    f.write(json.dumps({"id": 3, "text": "test"}) + "\n")

ARGS = {
    "path": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
reformat_case_byrules Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/format.py
code served (permissive licence) · get_code("b4a15f613c2098bb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import textwrap
import ast

def change_function_name(code, new_name):
    try:
        tree = ast.parse(code)
        for node in ast.walk(tree):
            if isinstance(node, ast.FunctionDef):
                if node.name != new_name:
                    node.name = new_name
                    break
                else:
                    break
        new_code = ast.unparse(tree)
        return new_code
    except Exception as e:
        return code

def reformat_case_byrules(testcase, func_name, lang='python'):
    if testcase.startswith(' '):
        testcase = textwrap.dedent(testcase)
    lines = testcase.split('\n')
    if lang == 'python':
        last_line = lines[-1]
        last_line = textwrap.dedent(last_line)
        try:
            compile(last_line, '<string>', 'exec')
        except:
            lines = lines[:-1]
    testcase = '\n'.join(lines)
    testcase = change_function_name(testcase, func_name)
    return testcase

# Setup code to construct valid arguments
testcase_simple = """
def old_function_name(x):
    return x + 1
result = old_function_name(5)
"""

testcase_indented = """
    def another_old_name(y):
        return y * 2
    print(another_old_name(3))
"""

testcase_multiline = """
def compute_sum(a, b):
    return a + b

output = compute_sum(10, 20)
"""

func_name_1 = "new_function_name"
func_name_2 = "renamed_function"
func_name_3 = "calculate_result"

lang_python = "python"
lang_javascript = "javascript"

ARGS = {
    "testcase": testcase_simple,
    "func_name": func_name_1,
    "lang": lang_python
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
remove_extra Ran
ran; our contract draft was wrong, not the code
llm4softwaretesting/testeval/format.py
code served (permissive licence) · get_code("4959d7997d3a14f1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

testcase_simple = """
def test():
    assert solution.my_func(5) == 10
    solution.my_func(3)
"""

testcase_with_extra = """
Some description before the test
More natural language here

def test():
    result = solution.my_func(5)
    assert result == 10
    solution.my_func(3)

Extra content after the solution call
More cleanup needed
"""

testcase_multiple_calls = """
def test():
    solution.my_func(1)
    solution.my_func(2)
    solution.my_func(3)
"""

ARGS = {
    'testcase': testcase_with_extra,
    'func_name': 'my_func',
    'lang': 'python'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
check_correctness Not yet run
unverified (harvested, no recorded run)
llm4softwaretesting/testeval/eval_overall.py
code served (permissive licence) · get_code("14f35d21477c79fd")
How it ran

no invocation recorded.

coverage_at_k_sample Not yet run
unverified (harvested, no recorded run)
llm4softwaretesting/testeval/eval_overall.py
code served (permissive licence) · get_code("db775593a397c583")
How it ran

no invocation recorded.

eval_correctness Not yet run
unverified (harvested, no recorded run)
llm4softwaretesting/testeval/eval_linecov.py
code served (permissive licence) · get_code("b524c61a6f2dd835")
How it ran

no invocation recorded.

testgeneration_multiround Not yet run
unverified (harvested, no recorded run)
llm4softwaretesting/testeval/generate_cov_gemini.py
code served (permissive licence) · get_code("ab6bc90d53359b17")
How it ran

no invocation recorded.

testgeneration_multiround Not yet run
unverified (harvested, no recorded run)
llm4softwaretesting/testeval/generate_cov_hf.py
code served (permissive licence) · get_code("75b3c705e3d449e4")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 15 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Testing plays a crucial role in the software development cycle, enabling the detection of bugs, vulnerabilities, and other undesirable behaviors. To perform software testing, testers need to write code snippets that execute the program under test. Recently, researchers have recognized the potential of large language models (LLMs) in software testing. However, there remains a lack of fair comparisons between different LLMs in terms of test case generation capabilities. In this paper, we propose TESTEVAL, a novel benchmark for test case generation with LLMs. We collect 210 Python programs from an online programming platform, LeetCode, and design three different tasks: overall coverage, targeted line/branch coverage, and targeted path coverage. We further evaluate sixteen popular LLMs, including both commercial and open-source ones, on TESTEVAL. We find that generating test cases to cover specific program lines/branches/paths is still challenging for current LLMs, indicating a lack of ability to comprehend program logic and execution paths. We have open-sourced our dataset and benchmark pipelines at https://github.com/LLM4SoftwareTesting/TestEval.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2406.04531")
get_code_for_paper("2406.04531")
have("2406.04531")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2406.04531.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2406.04531.svg)](https://syntology.ai/paper/2406.04531)

Connect an agent — have() is free.