Augmenting LLMs to Repair Obsolete Test Cases with Static Collector and Neural Reranker
<|reference_start|>Augmenting LLMs to Repair Obsolete Test Cases with Static Collector and Neural Reranker: During software evolution, it is advocated that test code should co-evolve with production code. In real development scenarios, test updating may lag behind production code changing, which may cause the project to fail to compile or bring other troubles. Existing techniques based on pre-trained language models can be adopted to repair obsolete tests caused by such unsynchronized code changes, especially syntactic-related ones. However, the lack of target-oriented contextual information affects repair accuracy on large-scale projects. Starting from an obsoleted test, the key challenging task is precisely identifying and constructing Test-Repair-Oriented Contexts (TROCtx) from the whole repository within a limited token size.   In this paper, we propose SynBCIATR (Syntactic-Breaking-Change-Induced Automated Test Repair), a novel approach to automatically repair obsolete test cases via precise and concise TROCtx construction. Inspired by developers' programming practices of the task, we design three types of TROCtx: class contexts, usage contexts, and environment contexts. For every type of TROCtx, SynBCIATR automatically collects the changed-token-related code information through static analysis techniques. Then it generates reranking queries to identify the most relevant TROCtxs, which will be taken as the repair-required key context and be input to the Large Language Model for the final test repair.   To evaluate the effectiveness of SynBCIATR, we construct a benchmark dataset that contains diverse syntactic breaking changes. The experimental results show that SynBCIATR outperforms baseline approaches both on textual- and intent-matching metrics. With the augmentation of TROCtx constructed by SynBCIATR, hallucinations are reduced by 57.1%.<|reference_end|>
@article{liu2024fix,
    title={Fix the Tests: Augmenting LLMs to Repair Test Cases with Static
  Collector and Neural Reranker},
    author={Jun Liu, Jiwei Yan, Yuanyuan Xie, Jun Yan, Jian Zhang},
    journal={arXiv preprint arXiv:2407.03625},
    year={2024},
    archivePrefix={arXiv},
    eprint={2407.03625},
    primaryClass={cs.SE}
}