Leveraging Change Types and Contexts to Guide LLMs for Automated Test Code Updating
In the continuous iteration of software, synchronizing the updates of test code and production code is crucial for ensuring project quality. However, in actual development, test code maintenance often lags behind the evolution of production code, which can lead to issues such as invalid functionality verification. Existing test code repair methods based on pre-trained models or Large Language Models (LLMs) show less effective or low generalization due to their lack of precise contextual awareness or strong limitations in use scenarios. This paper presents TestSyncer, a test case intelligent synchronization framework based on code change analysis and multi-dimensional context awareness. The framework innovatively combines three complementary dimensions: Change Types to identify multiple structural changes such as method signatures change and parameters change; Dependency Contexts to capture supporting elements like associated classes and interface definitions; and Caller Contexts to mine the actual usage patterns of methods in the project. These three-dimensional information can provide LLMs with the reasons why the test code is outdated, as well as its context-sensitive constraints, so that the larger model can better understand the task and generate repair code. To validate the effectiveness of the TestSyncer, we used a public evaluation dataset containing multiple Java projects evolving across versions and experimented with several mainstream LLMs. Experimental results show that TestSyncer improves the accuracy of test repairs by 85.5%, 70.7% and 53.7% compared to the baseline methods CEPROT, REACCEPT and Synter, respectively.