[Paper Review] Automated Test Case Repair Using Language Models
This paper proposes TARGET, a novel approach that treats automated test case repair as a language translation task using fine-tuned code language models (CLMs). It achieves 66.1% exact match accuracy and 80% plausible repair accuracy on a new benchmark, TARBENCH, which contains 45,373 broken test repairs across 59 open-source projects, demonstrating strong effectiveness and generalization across projects.
Ensuring the quality of software systems through testing is essential, yet maintaining test cases poses significant challenges and costs. The need for frequent updates to align with the evolving system under test often entails high complexity and cost for maintaining these test cases. Further, unrepaired broken test cases can degrade test suite quality and disrupt the software development process, wasting developers' time. To address this challenge, we present TaRGET (Test Repair GEneraTor), a novel approach leveraging pre-trained code language models for automated test case repair. TaRGET treats test repair as a language translation task, employing a two-step process to fine-tune a language model based on essential context data characterizing the test breakage. To evaluate our approach, we introduce TaRBench, a comprehensive benchmark we developed covering 45,373 broken test repairs across 59 open-source projects. Our results demonstrate TaRGET's effectiveness, achieving a 66.1% exact match accuracy. Furthermore, our study examines the effectiveness of TaRGET across different test repair scenarios. We provide a practical guide to predict situations where the generated test repairs might be less reliable. We also explore whether project-specific data is always necessary for fine-tuning and if our approach can be effective on new projects.
Motivation & Objective
- To address the high cost and complexity of maintaining test cases as systems evolve, especially when test failures stem from broken test code rather than system under test bugs.
- To develop an automated, generalizable solution for repairing broken test cases across diverse software projects and repair scenarios.
- To evaluate the effectiveness of code language models in test repair, particularly in handling both compilation and runtime errors.
- To provide practical guidance on when generated repairs are reliable and whether project-specific fine-tuning is necessary.
Proposed method
- TARGET formulates test repair as a sequence-to-sequence language translation task, transforming broken test code into repaired versions using pre-trained code language models.
- It employs a two-step fine-tuning process using essential context data—such as the system under test (SUT) changes and test failure symptoms—to guide repair generation.
- The approach leverages state-of-the-art code language models (e.g., CodeT5+ 770M and PLBART 140M) and fine-tunes them on project-specific data to improve repair accuracy.
- Context data includes SUT code changes (e.g., method visibility or exception type changes), failure type (compilation vs. runtime), and test code structure.
- A repair reliability prediction model is introduced to help developers filter low-quality generated repairs, improving practical usability.
- The study evaluates TARGET on TARBENCH, a new benchmark of 45,373 real-world broken test repairs from 59 open-source projects, covering diverse repair types and programming contexts.
Experimental results
Research questions
- RQ1Can code language models effectively repair broken test cases across diverse software projects and repair scenarios?
- RQ2How does incorporating context data (e.g., SUT changes and failure type) affect the performance of test repair models?
- RQ3Is project-specific fine-tuning necessary for high performance, or can models generalize to new projects?
- RQ4What factors reduce the reliability of generated repairs, and can we predict them?
- RQ5How do different code language models and fine-tuning strategies compare in terms of repair accuracy and efficiency?
Key findings
- TARGET achieved a 66.1% exact match accuracy and 80% plausible repair accuracy on the TARBENCH benchmark, significantly outperforming baseline methods.
- Incorporating context data improved performance by 37.4 percentage points in exact match accuracy, 24.1 in plausible repair accuracy, and 13.8 in both BLEU and CodeBLEU scores.
- The approach generalizes well to unseen projects, showing that project-specific fine-tuning is not always necessary for effective repair.
- Performance degrades on complex repairs involving multiple AST edit actions or multiple repair categories, with test oracles being repaired more reliably than other types.
- A small model like PLBART 140M achieved strong performance (close to CodeT5+ 770M), suggesting that high performance can be achieved with reduced computational cost.
- Reducing fine-tuning data size negatively impacts performance, with exact match accuracy dropping as data becomes scarcer.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.