π€ AI Summary
Existing automated unit test refactoring by LLMs lacks reliable, multidimensional evaluation metrics. Method: This paper proposes CTSES, the first composite evaluation framework that jointly models behavioral preservation, semantic consistency, readability, and structural validity. CTSES integrates CodeBLEU, METEOR, and ROUGE-L to enable joint quantification of renaming, structural reorganization, and semantic equivalence. We conduct large-scale experiments on the Defects4J and SF110 Java benchmarks using GPT-4o and Mistral-Large-2407, enhanced with Chain-of-Thought prompting. Results: Evaluated across 5,000+ test suites, CTSES significantly outperforms prior metrics (p < 0.01) and achieves high agreement with developer judgments and human evaluations (Spearmanβs Ο = 0.89). The framework substantially enhances the trustworthiness and practical utility of LLM-driven test refactoring.
π Abstract
Large Language Models (LLMs) are increasingly employed to automatically refactor unit tests, aiming to enhance readability, naming, and structural clarity while preserving functional behavior. However, evaluating such refactorings remains challenging: traditional metrics like CodeBLEU are overly sensitive to renaming and structural edits, whereas embedding-based similarities capture semantics but ignore readability and modularity. We introduce CTSES, a composite metric that integrates CodeBLEU, METEOR, and ROUGE-L to balance behavior preservation, lexical quality, and structural alignment. CTSES is evaluated on over 5,000 test suites automatically refactored by GPT-4o and Mistral-Large-2407, using Chain-of-Thought prompting, across two established Java benchmarks: Defects4J and SF110. Our results show that CTSES yields more faithful and interpretable assessments, better aligned with developer expectations and human intuition than existing metrics.