Code–Test Co-translation: Towards Practical and Effective Program Migration in the Wild
Xitao Li, Xiaofei Xie, Jiang Wu, Ting Liu, Haijun Wang
Key points
From the paper's conclusion- These results show that CoTTrans enhances translation stability and accuracy, establishing a practical foundation for reliable code–test co-evolution in real-world program migration.
Abstract
Program migration, which involves translating software systems from one programming language to another, is essential for modernizing legacy systems and improving maintainability. Recent large language models (LLMs) have demonstrated strong performance in code translation; however, existing methods and benchmarks still exhibit key limitations. (1) They primarily focus on simple, self-contained snippets that fail to capture the complexity of real-world programs, and (2) they often assume that target-language test cases are readily available for evaluation and feedback, an unrealistic assumption given the difficulty of manually creating equivalent tests across languages. In this paper, we argue for a more practical setting, termed the Code–Test Co-Translation (CTCT) problem, where both the program and its associated test suite should be jointly translated to preserve semantic and functional consistency. Through an empirical study on real-world programs, we identify two major challenges in CTCT: (1) the difficulty of measuring test-case consistency in the absence of ground truth, and (2) the ineffectiveness of existing iterative translation–repair strategies, which suffer from state degradation and poor initialization traps when handling complex, real-world features. To address these issues, we propose CoTTrans, a state-quality–aware iterative translation–repair framework guided by a novel Test Case Consistency (TCC) metric. TCC quantifies both syntactic and semantic consistency between source and translated tests, enabling fine-grained feedback that drives LLM-based refinement. CoTTrans further integrates TCC with test pass rates to assess state quality and triggers adaptive backtracking when low-quality states are detected during the translation. Evaluated on the BigCodeBench dataset, CoTTrans improves the translation correctness score from 0.360 to 0.675 on DeepSeek-V3, substantially outperforming existing methods, while TCC demonstrates superior effectiveness in measuring test consistency compared with existing metrics. These results show that CoTTrans enhances translation stability and accuracy, establishing a practical foundation for reliable code–test co-evolution in real-world program migration.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- CodeTransBenchmark: evaluating LLM-based code translation and repair across programming languagesEmpirical Software Engineering · 2026
- TransAgent: Enhancing LLM-Based Code Translation via Fine-Grained Execution AlignmentProceedings of the ACM on software engineering. · 2026
- A Survey of Code-to-Code Translation: From Statistical Rule-Based Systems to LLM AgentsAlgorithms · 2026
- Bootstrapping Niche Multilingual Code Translation via Reinforcement Learning with Execution-Based Verifiable SupervisionarXiv · 2026
- CodeMeepo: A Multi-Agent Workflow for Repository-Level Code Migration and OptimizationarXiv · 2026
- Hallucinations of Large Language Models in Cross-Language Code Translation: Phenomena and MitigationarXiv · 2026