# Attention Transfer Reinforcement Learning for Test Case Prioritization in Continuous Integration
## 1 Introduction
The sorting is still based on the features of individual test cases. Unlike the aforementioned methods, [PERSON] et al. proposed pointer ranking (PRM) method and incorporated all test case characteristics into a model [10]. PRM considers the relative relationships between test cases to improve the overall performance of the global prioritization process. The PRM method directly inputs all test case features into the model. The model uses an attention mechanism to consider the features of all other test cases. The relative order of the test cases is then chosen as the basis for ranking. PRM effectively considers the relative relationships between test cases, and performs well for large datasets with many test cases. However, when the number of test cases is small and some test cases are repeatedly executed across multiple integration cycles, the characteristics of these test cases become very prominent. In such cases, the model should focus more on the features of these individual test cases. If PRM is still used, it leads to prioritizing the relationships between test cases while neglecting the rich information of individual test cases. As observed in [10], PRM performs poorly on the Paint Control dataset, as it contains a small number of test cases with frequent re-executions and rich historical information. Furthermore, due to the sparse reward issue, PRM methods may experience performance degradation. The reason for this is that PRM overlooks the fault detection capability of individual test cases, resulting in reduced learnable rewards. Therefore, its performance may decline when applied in comprehensive scenarios. To simultaneously focus on the features of individual test cases and the relationships between test cases in the dataset, we propose an attention-based reinforcement learning TCP method. In this approach, the model processes the features of all test cases simultaneously. Based on the richness of historical information and the fault detection capabilities of the test cases, the model determines whether to focus on individual test cases or the relative relationships between them. When a test case has extensive historical execution data and a high defect detection rate, the model should prioritize its fault detection ability. On the other hand, when historical information is sparse, the model should focus on the relative relationships between test cases from a global perspective, facilitating a \"shift in model attention\". This approach enables the model to adaptively adjust its optimization strategy based on the characteristics of the test case set in different iteration cycles, thereby enhancing its generalization ability. In this paper, we compare the performance of our method with RETECS and PRM methods on four datasets (Paint Control, IOF/ROL, GSDTSR, Apach Drill). We also explore the impact of factors such as the length of historical information and error rate on the performance of our method. The execution efficiency of the three methods was compared through experiments. The contributions of this paper are threefold. Firstly, we propose a guided attention mechanism that utilizes vectors to direct the generation of attention weights. It ensures that the weights generated have directionality and purpose to shift the model's focus. ATRL-TCP can fully consider the feature information of the test cases to be prioritized during sorting. If the historical execution information of a test case is rich, the model prioritizes sorting rewards based on the individual test case. If the test case features are less prominent, relative order is considered for sorting. In practical applications, this approach can adapt to various types of test case sets, achieving excellent sorting performance. Secondly, the effectiveness of this technique is validated on four industrial datasets, which encompass the diverse scenarios that ATRL-TCP is designed to address. Our results demonstrate that the proposed method achieves superior TCP performance, significantly outperforming standard methods on average.