mlsanityData to 7 Oct 2026

Automated Unit Test Refactoring

arXiv 2409.16739 ↗First posted 25 Sep 2024cs.SEcited by 4

Not on the map. Why?

Abstract (arXiv)

Test smells arise from poor design practices and insufficient domain knowledge, which can lower the quality of test code and make it harder to maintain and update. Manually refactoring test smells is time-consuming and error-prone, highlighting the necessity for automated approaches. Current rule-based refactoring methods often struggle in scenarios not covered by predefined rules and lack the flexibility needed to handle diverse cases effectively. In this paper, we propose a novel approach called UTRefactor, a context-enhanced, LLM-based framework for automatic test refactoring in Java projects. UTRefactor extracts relevant context from test code and leverages an external knowledge base that includes test smell definitions, descriptions, and DSL-based refactoring rules. By simulating the manual refactoring process through a chain-of-thought approach, UTRefactor guides the LLM to eliminate test smells in a step-by-step process, ensuring both accuracy and consistency throughout the refactoring. Additionally, we implement a checkpoint mechanism to facilitate comprehensive refactoring, particularly when multiple smells are present. We evaluate UTRefactor on 879 tests from six open-source Java projects, reducing the number of test smells from 2,375 to 265, achieving an 89% reduction. UTRefactor outperforms direct LLM-based refactoring methods by 61.82% in smell elimination and significantly surpasses the performance of a rule-based test smell refactoring tool. Our results demonstrate the effectiveness of UTRefactor in enhancing test code quality while minimizing manual involvement.

Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). First posted on arXiv 25 Sep 2024.

Builds on

No reference list yet.

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 4.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025Testing Refactoring Engine via Historical Bug Report driven LLM ↗
  2. 2026RefactorAssist: Agentic Refinement for Reliable Code Refactoring
  3. 2026REFINE: A Multi-Agent LLM Approach for Evidence-Guided Code Refactoring
  4. 2026SmellBench: Towards Fine-Grained Evaluation of Code Agents on Refactoring Tasks
  5. 2026TAM-Eval: Evaluating LLMs for Automated Unit Test Maintenance
  6. 2024An Empirical Study on the Code Refactoring Capability of Large Language Models
  7. 2025Learning to Generate Unit Tests for Automated Debugging
  8. 2025MANTRA: Enhancing Automated Method-Level Refactoring with Contextual RAG and Multi-Agent LLM Collaboration