Testing Method Relocation Algorithms via Template-Based Systematic Structural Traversal and Precondition Filtering
Chunhao Dong, Yanjie Jiang, Yang Zhang, Hui Liu
Abstract
Method relocation refactorings, primarily Move Method and Pull Up/Push Down Method, are indispensable for reducing coupling and enhancing cohesion. Despite their widespread automation in modern refactoring engines, these algorithms remain notoriously error-prone, posing significant risks to software reliability. A primary challenge in testing them lies in the vast search space of complex program structures and the intricate preconditions required for safe method relocation. To address this, we propose RelocTest, a comprehensive testing framework that combines template-driven structural traversal with automated precondition filtering. RelocTest systematically explores the input space by populating program templates specially designed for method relocation through a two-stage generation process: (1) Skeleton Synthesis, which systematically traverses diverse syntactic structures, and (2) LLM-Guided Completion, which leverages Large Language Models to inject diverse, executable code into these skeletons. This hybrid strategy ensures high structural coverage while maintaining test program validity. Furthermore, to optimize testing efficiency, we introduce an LLM-based Precondition Extractor that analyzes the implementation of method relocation algorithms to identify and prune test programs destined for rejection. We evaluated RelocTest on 7 mainstream refactoring engines. Our approach successfully uncovered 56 previously unknown bugs, with 19 already confirmed by tool vendors, demonstrating its effectiveness in hardening industrial-strength refactoring tools.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Related papers
- Cross-Refactoring-Type Test Program Migration for Refactoring EnginesChunhao Dong, Yanjie Jiang, Yang Zhang, Yuxia Zhang et al.FSE 2026
- Chatgpt-Based Test Generation for Refactoring Engines Enhanced by Feature Analysis on ExamplesChunhao Dong, Yanjie Jiang, Yuxia Zhang, Yang Zhang et al.ICSE 2025 · 4 citations
- Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMsZhiyi Lyu, Jianguo Huang, Yanchen Deng, Steven Hoi et al.NeurIPS 2025 · 7 citations
- LLMSQLMUTATOR: LLM-Powered Test Case Generation for Database Using Bug ReportsChenglin Tian, Chaofan Li, Yawen Li, Yingxia ShaoICDE 2026
- Clozemaster: Fuzzing Rust Compiler by Harnessing Llms for Infilling Masked Real ProgramsHongyan Gao, Yibiao Yang, Maolin Sun, Jiangchang Wu et al.ICSE 2025 · 6 citations
