This work addresses test output prediction, a key challenge in test case generation. To improve the reliability of predicted outputs by LLMs, prior approaches generate code first to ground predictions. One grounding strategy is direct execution of generated code, but even minor errors can cause failures. To address this, we introduce LLM-based pseudocode execution, which grounds prediction on more error-resilient pseudocode and simulates execution via LLM reasoning. We further propose DuET, a dual-execution framework that combines both approaches by functional majority voting. Our analysis shows the two approaches are complementary in overcoming the limitations of direct execution suffering from code errors, and pseudocode reasoning from hallucination. On LiveCodeBench, DuET achieves the state-of-the-art performance, improving Pass@1 by 13.6 pp.
Figures & tables
Figure 1: Comparison of test output prediction methods: (a) TestChain Li and Yuan (2024) grounds generated code and executes it directly. (b) LLM-based Pseudocode Execution grounds generated pseudocode and simulates its execution via an LLM. (c) DuET combines both code and pseudocode grounding, executing them via direct and LLM-based paths, respectively.
Figure 2: (a) The problem involves complex functional logic that is accurately captured in the generated pseudocode but mistranslated into executable code (i.e., implementation errors) . (b) Both the generated code and pseudocode are correct, but simulating the pseudocode (e.g., involving deeply nested loops) introduces reasoning challenges that lead to LLM prediction errors (i.e., execution hallucinations) .
Figure 3: Overview of our dual-execution framework for test output prediction. Given a problem description and input, we perform two separate executions in parallel. In the left path, we generate pseudocode and use an LLM to reason over it to predict the output (i.e., LLM-based pseudocode execution ). In the right path, we generate pseudocode independently, translate it into executable code, and run it on the input to obtain the output (i.e., direct code execution ). Multiple outputs from both paths are aggregated via path-weighted functional majority voting to determine the final prediction.
Method
Pass@ 1
Llama-3-8B-Instruct †
27.2
Mixtral-8x22B-Instruct †
45.6
Mistral-Large †
48.6
Gemini-Pro-1.5-May †
48.6
Dracarys-Llama-3.1-70B-Instruct †
49.1
Dracarys2-Llama-3.1-70B-Instruct †
52.1
Table 1: Test output prediction results on LiveCodeBench (May 1, 2023–Apr 1, 2024). Red-colored models have a knowledge cutoff after this date, introducing the possibility of data contamination. Daggered ( † ) results are sourced from the leader board. 7 7 7 https://livecodebench.github.io/leaderboard.html 8 8 8 We treat unbiased Pass@ k as random selection (see Appendix K.3 ).
Method
Ground.
Exec.
Pass@ 1
GPT-4-Turbo-2024-04-09
-
-
72.3684210526315
TestChain
C
D
74.34210526
DuET
C & P
D & L
81.57894737
- direct code exec.
P
L
69.07894737
Llama-3.1-8B-Inst
-
-
34.01315789
TestChain
C
D
46.27192982
Table 2: Pass@ 1 comparison on the LiveCodeBench test output prediction benchmark (Jan 1–Apr 1, 2024). Functional majority voting is applied to all baselines by default. Each method is labeled by its grounding type, code (C) or pseudocode (P), and execution type, direct (D) or LLM-based (L).
Method
Grounding
Execution
Pass@ 1
Pass@ 2
Pass@ 5
Pass@ 10
No Filtering
-
-
33.9
50.9
64.8
73.3
CodeT
-
-
54.2
62.8
71.3
74.3
TestChain
Code
Direct
48.6
54.9
61.4
67.6
DuET
Code & Pseudocode
Direct & LLM-based
57.4
65.2
71.8
75.1
- direct code exec.
Pseudocode
LLM-based
55.9
64.5
71.8
75.1
Table 3: End-to-end code generation performance of Llama-3.1-8B-Instruct under different test output prediction methods, evaluated on LiveCodeBench-Easy (Jan 1, 2024–Feb 1, 2025).
Figure 4: Illustrative example of TestChain’s zero-advantage problem in end-to-end code generation, where test input ( Input: (2, 3) ) is generated by CodeT .
Figure 5: Pass@ 1 scores of execution methods on LiveCodeBench test output prediction (Jan 1–Apr 1, 2024) by GPT-4-Turbo-2024-04-09 , across problem subsets based on the generated code correctness.
Grounding
Direct Exec.
LLM-based Exec.
Code
TestChain
LLM-based Code Exec.
Pseudocode
-
LLM-based Pseudo. Exec.
Table 4: Design space taxonomy, categorized by execution target (code vs. pseudocode) and an execution mode (direct vs. LLM-based). DuET , marked as a pink diagonal box, chooses the best combination of direct code execution and LLM-based pseudocode execution .
Figure 6: Pass@1 across bins of generated code execution trace lengths on LiveCodeBench test output prediction (Jan 1–Apr 1, 2024) by GPT-4-Turbo-2024-04-09 . Each execution step corresponds to a single line of code executed during code execution.
Method
Ground.
Exec.
Pass@ 1
no grounding
-
-
74.2458521870286
direct code exec. (TestChain)
C
D
75.4524886877828
LLM-based code exec.
C
L
72.24736048265461
LLM-based pseudocode exec.
P
L
74.05731523378581
direct & LLM-based code exec.
C
D & L
77.37556561085974
LLM-based code & pseudo. exec.
C & P
L
73.64253393665159
Table 5: Test output prediction results of GPT-4-Turbo-2024-04-09 across grounding combinations and execution methods on LiveCodeBench (May 1, 2023–Apr 1, 2024). Functional majority voting is applied across methods. We highlight representative baselines and our methods using distinct colors: TestChain , LLM-based pseudocode execution , and DuET . Variants that use LLM-based code execution (alone or in combination) are marked in blue. Each method is labeled by its grounding type, code (C) or pseudocode (P), and execution type, direct (D) or LLM-based (L).
Method
Ground.
Exec.
Pass@ 1
No Filtering
-
-
24.04
CodeT
-
-
22.61
TestChain
C
D
24.04
DuET
C & P
D & L
25.34
- direct code exec.
P
L
24.04
Table 6: End-to-end code generation performance of QwQ-32B under different test output prediction methods, evaluated on BigCodeBench-Hard.
Figure 7: End-to-end code generation performance of Llama-3.1-8B-Instruct evaluated on DevEval (See Appendix F for the full results).
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
Pseudocode
LLM-based
Pass@1
Granularity
Execution
Low
Step-by-step (default)
31.1
Low
3-step
31.3
Mid (default)
Step-by-step (default)
34.4
Mid (default)
3-step
32.5
High
Step-by-step (default)
25.1
Appendix
Table 7: Test output prediction performance comparison of Llama-3.1-8B-Instruct with LLM-based pseudocode execution over prompt design choices on LiveCodeBench (May 1, 2023–Apr 1, 2024). Rows vary the granularity of the generated pseudocode (low, mid, high), while columns compare two LLM-based execution prompting strategies: a step-by-step simulation and a condensed 3-step reasoning format. Default settings are indicated in parentheses. Functional majority voting is applied with 10 independent samples per output.
Model
Grounding
Execution
Pass@ 1
All
Easy
Medium
Hard
Llama-3.1-8B-Instruct
-
-
34.01315789
35.28571429
40.90909091
23.68421053
TestChain
Code
Direct
46.27192982
55.23809524
51.51515152
23.68421053
DuET
Code & Pseudocode
Direct & LLM-based
53.28947368
61.42857143
62.5
27.63157895
- direct code exec.
Pseudocode
LLM-based
34.38596491
35.14285714
27.27272727
41.22807018
Appendix
Table 8: Test output prediction results on LiveCodeBench (Jan 1–Apr 1, 2024), where difficulty levels of test inputs are estimated using the correctness rate of code generated by the best performing model ( GPT-4-Turbo-2024-04-09 ). Functional majority voting is applied to all baselines by default.
Model
Grounding
Execution
Pass@ 1
All
Easy
Medium
Hard
Llama-3.1-8B-Instruct
-
-
34.01315789
39
35.25
18.18181818
TestChain
Code
Direct
46.27192982
58
39.58333333
43.93939394
DuET
Code & Pseudocode
Direct & LLM-based
53.28947368
64
51.25
36.36363636
- direct code exec.
Pseudocode
LLM-based
34.38596491
46.4
28.83333333
27.27272727
Appendix
Table 9: Pass@ 1 performance on the LiveCodeBench test output prediction benchmark (Jan 1–Apr 1, 2024), where difficulty levels follow the original LiveCodeBench setting based on the problem’s difficulty. Functional majority voting is applied to all baselines by default.
Method
Grounding
Execution
Pass@ 1
HumanEval
HumanEval+
No Filtering
-
-
79.2
69.9
CodeT
-
-
84.7
75.0
TestChain
Code
Direct
83.0
73.6
DuET
Code & Pseudocode
Direct & LLM-based
85.1
75.4
- direct code exec.
Pseudocode
LLM-based
84.8
75.2
Appendix
Table 10: End-to-end code generation performance of Llama-3.1-70B-Instruct under different test output prediction methods, evaluated on HumanEval and HumanEval+.
Figure 8: End-to-end code generation performance of Llama-3.1-8B-Instruct evaluated on DevEval.
Method
Ground.
Exec.
Pass@ 1
GPT-4-Turbo-2024-04-09
-
-
72.3684210526315
TestChain
C
D
74.34210526
DuET
C & P
D & L
81.57894737
- direct code exec.
P
L
69.07894737
Llama-3.1-8B-Inst
-
-
34.01315789
TestChain
C
D
46.27192982
Appendix
Table 11: Pass@ 1 comparison on the LiveCodeBench test output prediction benchmark (Jan 1–Apr 1, 2024). Functional majority voting is applied to all baselines by default. Each method is labeled by its grounding type, code (C) or pseudocode (P), and execution type, direct (D) or LLM-based (L). Red-colored models have the possibility of data contamination.
Model
DuET Voting Method
Pass@ 1
GPT-4-Turbo-2024-04-09
functional majority voting
81.6
+ path-weighted
81.6
Llama-3.1-8B-Inst
functional majority voting
53.3
+ path-weighted
53.3
Llama-3.1-70B-Inst
functional majority voting
77.6315789473684
+ path-weighted
78.3
Appendix
Table 12: The effect of path-weighted FMV on the LiveCodeBench test output prediction benchmark (Jan 1–Apr 1, 2024). Red-colored models have the possibility of data contamination.
Test case synthesis is crucial for evaluating and ranking programs generated by large language models (LLMs). However, constructing high-quality test cases remains challenging because reliable expected outputs are often difficult to obtain. We propose Confidence-Gated Transductive Test Generation (CoTT), which first uses an efficient inductive procedure and invokes transductive generation only when inductive confidence is low. This adaptive design improves output reliability while allocating extra computation only when needed. On code reranking benchmarks, CoTT outperforms prior baselines across the reported metrics while reducing cost relative to applying transductive generation to every input. These results show that confidence-based allocation of test-time computation provides a favorable efficiency-effectiveness trade-off with a single efficient LLM.
Sungjae Lee, Youngsik Yoon, Seockbean Song +3
Department of Computer Science and Engineering, POSTECH, South Korea · Graduate School of Artificial Intelligence, POSTECH, South Korea · Microsoft Research Asia, China
State-of-the-art code generation frameworks rely on mental simulation, where LLMs internally trace execution to verify correctness. We expose a fundamental limitation: the Mental-Reality Gap -- where models hallucinate execution traces and confidently validate buggy code. This gap manifests along two orthogonal dimensions: the Specification Gap (overlooking edge cases during planning) and the Verification Gap (hallucinating correct behavior for flawed code). We propose SolidCoder with a simple principle: don't imagine -- execute. The S.O.L.I.D. architecture addresses both dimensions by forcing edge-case awareness before algorithm design and replacing imagined traces with sandboxed execution using property-based oracles. With GPT-4o, SolidCoder achieves state-of-the-art pass@1 performance: 95.7% on HumanEval (+0.6%p), 77.0% on CodeContests (+4.3%p), and 26.7% on APPS (+3.4%p). Ablation reveals that edge-case awareness provides the largest individual gain, while execution grounding catches categorically different errors that specification improvements cannot address. These gains generalize to RL post-trained models, validating that bridging both gap dimensions is essential for robust code synthesis. We release our code and framework to facilitate future research.
Woojin Lee, Jin-Xia Huang
Electronics and Telecommunications Research Institute, Republic of Korea
The use of LLMs for code generation has naturally extended to code testing and evaluation. As codebases grow in size and complexity, so does the need for automated test generation. Current approaches for LLM-based test generation rely on strategies that maximize immediate coverage gain, a greedy approach that plateaus on code where reaching deep branches requires setup steps that individually yield zero new coverage. Drawing on principles of Bayesian exploration, we treat the program's branch structure as an unknown environment, and an evolving coverage map as a proxy probabilistic posterior representing what the LLM has discovered so far. Our method, CovQValue, feeds the coverage map back to the LLM, generates diverse candidate plans in parallel, and selects the most informative plan by LLM-estimated Q-values, seeking actions that balance immediate branch discovery with future reachability. Our method outperforms greedy selection on TestGenEval Lite, achieving 51-77% higher branch coverage across three popular LLMs and winning on 77-84% of targets. In addition, we build a benchmark for iterative test generation, RepoExploreBench, where they achieve 40-74%. These results show the potential of curiosity-driven planning methods for LLM-based exploration, enabling more effective discovery of program behavior through sequential interaction
Alfonso Amayuelas, Firas Laakom, Piotr Piękos +5
University of California, Santa Barbara · King Abdullah University of Science and Technology