# Attention Transfer Reinforcement Learning for Test Case Prioritization in Continuous Integration
## 1 Introduction  
CI is a practice of software development that involves frequently integrating code changes into a shared repository. It automates the process of building, testing, and deploying software to ensure the codebase remains in a deployable state. CI improves collaboration, reduces integration issues, and accelerates the development cycle. However, it still faces challenges in providing rapid feedback to developers. CI involves tasks suchas version control, software configuration management, automatic builds, and regression testing. Regression testing ensures that new code updates do not introduce errors or affect existing functionality [1]. By executing a defined set of test cases and observing whether the software passes all tests, it ensures that the updated code does not introduce new errors and does not affect the existing functionality of the software. However, as the size of the test suite increases, the time and resource costs of regression testing become more demanding [2]. Regression testing has been shown to be a critical bottleneck in CI efficiency [3]. Unlike traditional regression testing, the test cases of CI regression testing change with code iterations. Determining how to execute these test cases to detect errors as early as possible is a challenge for researchers. To address this issue, test case prioritization (TCP) techniques have been proposed. The basic idea is to rank the elements of the test suite, prioritizing tests that are likely to reveal defects and are shorter in execution time. This approach aims to expose software defects promptly and provide developers with rapid feedback. In different cycles of CI, the software's functionality changes with user requirements. Classic TCP algorithms need to collect coverage information [4], code dependencies [5], test distribution analysis [6; 7; 8], and other related data. Obtaining this information consumes a significant amount of time, and needs to be recalculated in each cycle. Traditional TCP algorithms struggle to account for the changes in test cases during ranking. Therefore, TCP methods that rely on these statistical data are not effectively applicable in CI. Machine learning (ML) algorithms are also employed in the TCP task by developing models that autonomously generate rankings. Reinforcement learning, a branch of ML, allows the learner to make decisions based on interaction with the environment, selecting actions and receiving reward feedback. The learner adjusts its strategy based on these rewards, reinforcing actions that lead to higher rewards. [PERSON] et al. introduced RETECS, the first reinforcement-learning-based method, which calculates and outputs the priority of test cases based on their characteristics [9]. RETECS selects test cases and determines priorities using historical execution data and estimated execution times. Through interaction with the environment, the agent is incentivized by a reward function to take actions that support the set goals. In each integration cycle, the agent processes the features of a test case, outputs its priority, and sorts all test cases accordingly. They proposed three reward functions, i.e., failure count reward, test case failure reward, and time-ranked reward, and tested them on three industrial-grade programs. RETECS primarily uses the feature information of individual test cases as input to the model. When the feature information of the test cases to be sorted is insufficient, the model struggles to obtain effective reward signals, resulting in poor sorting performance. As shown in [9], RETECS performs poorly in the GSDTSR dataset. This is because the GSDTSR dataset contains a large number of test cases, with each test case executed relatively few times. RETECS cannot gather sufficient execution information for the test cases, leading to suboptimal sorting results. Building on the work of RETECS, many researchers have explored more diverse reward functions and mechanisms. However, the nature of the input has not fundamentally changed.